@@ -60,7 +60,7 @@ static const secp256k1_context secp256k1_context_no_precomp_ = {
60
60
const secp256k1_context * secp256k1_context_no_precomp = & secp256k1_context_no_precomp_ ;
61
61
62
62
size_t secp256k1_context_preallocated_size (unsigned int flags ) {
63
- size_t ret = ROUND_TO_ALIGN ( sizeof (secp256k1_context ) );
63
+ size_t ret = sizeof (secp256k1_context );
64
64
/* A return value of 0 is reserved as an indicator for errors when we call this function internally. */
65
65
VERIFY_CHECK (ret != 0 );
66
66
@@ -74,13 +74,12 @@ size_t secp256k1_context_preallocated_size(unsigned int flags) {
74
74
}
75
75
76
76
size_t secp256k1_context_preallocated_clone_size (const secp256k1_context * ctx ) {
77
- size_t ret = ROUND_TO_ALIGN ( sizeof (secp256k1_context ) );
77
+ size_t ret = sizeof (secp256k1_context );
78
78
VERIFY_CHECK (ctx != NULL );
79
79
return ret ;
80
80
}
81
81
82
82
secp256k1_context * secp256k1_context_preallocated_create (void * prealloc , unsigned int flags ) {
83
- void * const base = prealloc ;
84
83
size_t prealloc_size ;
85
84
secp256k1_context * ret ;
86
85
@@ -93,7 +92,7 @@ secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigne
93
92
return NULL ;
94
93
}
95
94
VERIFY_CHECK (prealloc != NULL );
96
- ret = (secp256k1_context * )manual_alloc ( & prealloc , sizeof ( secp256k1_context ), base , prealloc_size ) ;
95
+ ret = (secp256k1_context * )prealloc ;
97
96
ret -> illegal_callback = default_illegal_callback ;
98
97
ret -> error_callback = default_error_callback ;
99
98
@@ -102,7 +101,7 @@ secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigne
102
101
secp256k1_ecmult_gen_context_build (& ret -> ecmult_gen_ctx );
103
102
ret -> declassify = !!(flags & SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY );
104
103
105
- return ( secp256k1_context * ) ret ;
104
+ return ret ;
106
105
}
107
106
108
107
secp256k1_context * secp256k1_context_create (unsigned int flags ) {
@@ -117,14 +116,12 @@ secp256k1_context* secp256k1_context_create(unsigned int flags) {
117
116
}
118
117
119
118
secp256k1_context * secp256k1_context_preallocated_clone (const secp256k1_context * ctx , void * prealloc ) {
120
- size_t prealloc_size ;
121
119
secp256k1_context * ret ;
122
120
VERIFY_CHECK (ctx != NULL );
123
121
ARG_CHECK (prealloc != NULL );
124
122
125
- prealloc_size = secp256k1_context_preallocated_clone_size (ctx );
126
123
ret = (secp256k1_context * )prealloc ;
127
- memcpy ( ret , ctx , prealloc_size ) ;
124
+ * ret = * ctx ;
128
125
return ret ;
129
126
}
130
127
0 commit comments