Skip to content

Commit 059012f

Browse files
committed
Split secp256k1_ecmult_context_teardown() out of secp256k1_ecmult_context_clear
The 'teardown' naming is to complement the 'build' function name. To 'build' allocates and sets up the memory for pre_g and pre_g_128. To 'teardown' frees the memory.
1 parent ad225e8 commit 059012f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/ecmult.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx);
2222
static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb);
2323
static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst,
2424
const secp256k1_ecmult_context *src, const secp256k1_callback *cb);
25+
static void secp256k1_ecmult_context_teardown(secp256k1_ecmult_context *ctx);
2526
static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx);
2627
static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx);
2728

src/ecmult_impl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,14 @@ static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx
217217
return ctx->pre_g != NULL;
218218
}
219219

220-
static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx) {
220+
static void secp256k1_ecmult_context_teardown(secp256k1_ecmult_context *ctx) {
221221
free(ctx->pre_g);
222222
#ifdef USE_ENDOMORPHISM
223223
free(ctx->pre_g_128);
224224
#endif
225+
}
226+
227+
static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx) {
225228
secp256k1_ecmult_context_init(ctx);
226229
}
227230

src/secp256k1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
9191

9292
void secp256k1_context_destroy(secp256k1_context* ctx) {
9393
if (ctx != NULL) {
94+
secp256k1_ecmult_context_teardown(&ctx->ecmult_ctx);
9495
secp256k1_ecmult_context_clear(&ctx->ecmult_ctx);
9596
secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);
9697

0 commit comments

Comments
 (0)