Skip to content

Commit

Permalink
fixup! Support cloning a context into preallocated memory
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Nov 27, 2018
1 parent 4846ca3 commit bf35e5d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/secp256k1.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ size_t secp256k1_context_preallocated_size(unsigned int flags) {
return ret;
}

size_t secp256k1_context_preallocated_size_for_clone(const secp256k1_context* ctx) {
size_t secp256k1_context_preallocated_clone_size(const secp256k1_context* ctx) {
size_t ret = ROUND_TO_ALIGN(sizeof(secp256k1_context));
VERIFY_CHECK(ctx != NULL);
if (secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)) {
Expand Down Expand Up @@ -144,7 +144,7 @@ secp256k1_context* secp256k1_context_preallocated_clone(const secp256k1_context*
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(prealloc != NULL);

prealloc_size = secp256k1_context_preallocated_size_for_clone(ctx);
prealloc_size = secp256k1_context_preallocated_clone_size(ctx);
ret = (secp256k1_context*)prealloc;
memcpy(ret, ctx, prealloc_size);
secp256k1_ecmult_gen_context_finalize_memcpy(&ret->ecmult_gen_ctx, &ctx->ecmult_gen_ctx);
Expand All @@ -157,7 +157,7 @@ secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
size_t prealloc_size;

VERIFY_CHECK(ctx != NULL);
prealloc_size = secp256k1_context_preallocated_size_for_clone(ctx);
prealloc_size = secp256k1_context_preallocated_clone_size(ctx);
ret = (secp256k1_context*)checked_malloc(&ctx->error_callback, prealloc_size);
ret = secp256k1_context_preallocated_clone(ctx, ret);
return ret;
Expand Down

0 comments on commit bf35e5d

Please sign in to comment.