@@ -60,7 +60,7 @@ static const secp256k1_context secp256k1_context_no_precomp_ = {
6060const secp256k1_context * secp256k1_context_no_precomp = & secp256k1_context_no_precomp_ ;
6161
6262size_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 );
6464 /* A return value of 0 is reserved as an indicator for errors when we call this function internally. */
6565 VERIFY_CHECK (ret != 0 );
6666
@@ -74,13 +74,12 @@ size_t secp256k1_context_preallocated_size(unsigned int flags) {
7474}
7575
7676size_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 );
7878 VERIFY_CHECK (ctx != NULL );
7979 return ret ;
8080}
8181
8282secp256k1_context * secp256k1_context_preallocated_create (void * prealloc , unsigned int flags ) {
83- void * const base = prealloc ;
8483 size_t prealloc_size ;
8584 secp256k1_context * ret ;
8685
@@ -93,7 +92,7 @@ secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigne
9392 return NULL ;
9493 }
9594 VERIFY_CHECK (prealloc != NULL );
96- ret = (secp256k1_context * )manual_alloc ( & prealloc , sizeof ( secp256k1_context ), base , prealloc_size ) ;
95+ ret = (secp256k1_context * )prealloc ;
9796 ret -> illegal_callback = default_illegal_callback ;
9897 ret -> error_callback = default_error_callback ;
9998
@@ -102,7 +101,7 @@ secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigne
102101 secp256k1_ecmult_gen_context_build (& ret -> ecmult_gen_ctx );
103102 ret -> declassify = !!(flags & SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY );
104103
105- return ( secp256k1_context * ) ret ;
104+ return ret ;
106105}
107106
108107secp256k1_context * secp256k1_context_create (unsigned int flags ) {
@@ -117,14 +116,12 @@ secp256k1_context* secp256k1_context_create(unsigned int flags) {
117116}
118117
119118secp256k1_context * secp256k1_context_preallocated_clone (const secp256k1_context * ctx , void * prealloc ) {
120- size_t prealloc_size ;
121119 secp256k1_context * ret ;
122120 VERIFY_CHECK (ctx != NULL );
123121 ARG_CHECK (prealloc != NULL );
124122
125- prealloc_size = secp256k1_context_preallocated_clone_size (ctx );
126123 ret = (secp256k1_context * )prealloc ;
127- memcpy ( ret , ctx , prealloc_size ) ;
124+ * ret = * ctx ;
128125 return ret ;
129126}
130127
0 commit comments