2023-09-27 18:37:09 +00:00
|
|
|
140,150d139
|
2019-10-21 15:06:23 +00:00
|
|
|
< secp256k1_context* secp256k1_context_create(unsigned int flags) {
|
|
|
|
< size_t const prealloc_size = secp256k1_context_preallocated_size(flags);
|
|
|
|
< secp256k1_context* ctx = (secp256k1_context*)checked_malloc(&default_error_callback, prealloc_size);
|
|
|
|
< if (EXPECT(secp256k1_context_preallocated_create(ctx, flags) == NULL, 0)) {
|
|
|
|
< free(ctx);
|
|
|
|
< return NULL;
|
|
|
|
< }
|
|
|
|
<
|
|
|
|
< return ctx;
|
|
|
|
< }
|
|
|
|
<
|
2023-09-27 18:37:09 +00:00
|
|
|
162,174d150
|
2019-10-21 15:06:23 +00:00
|
|
|
< secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
|
|
|
|
< secp256k1_context* ret;
|
|
|
|
< size_t prealloc_size;
|
|
|
|
<
|
|
|
|
< VERIFY_CHECK(ctx != NULL);
|
2023-09-27 18:37:09 +00:00
|
|
|
< ARG_CHECK(secp256k1_context_is_proper(ctx));
|
|
|
|
<
|
2019-10-21 15:06:23 +00:00
|
|
|
< 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;
|
|
|
|
< }
|
|
|
|
<
|
2023-09-27 18:37:09 +00:00
|
|
|
186,197d161
|
2019-10-21 15:06:23 +00:00
|
|
|
< void secp256k1_context_destroy(secp256k1_context* ctx) {
|
2023-09-27 18:37:09 +00:00
|
|
|
< ARG_CHECK_VOID(ctx == NULL || secp256k1_context_is_proper(ctx));
|
|
|
|
<
|
|
|
|
< /* Defined as noop */
|
|
|
|
< if (ctx == NULL) {
|
|
|
|
< return;
|
2019-10-21 15:06:23 +00:00
|
|
|
< }
|
2023-09-27 18:37:09 +00:00
|
|
|
<
|
|
|
|
< secp256k1_context_preallocated_destroy(ctx);
|
|
|
|
< free(ctx);
|
2019-10-21 15:06:23 +00:00
|
|
|
< }
|
|
|
|
<
|
2023-09-27 18:37:09 +00:00
|
|
|
220,229d183
|
2019-10-21 15:06:23 +00:00
|
|
|
< }
|
|
|
|
<
|
|
|
|
< secp256k1_scratch_space* secp256k1_scratch_space_create(const secp256k1_context* ctx, size_t max_size) {
|
|
|
|
< VERIFY_CHECK(ctx != NULL);
|
|
|
|
< return secp256k1_scratch_create(&ctx->error_callback, max_size);
|
|
|
|
< }
|
|
|
|
<
|
|
|
|
< void secp256k1_scratch_space_destroy(const secp256k1_context *ctx, secp256k1_scratch_space* scratch) {
|
|
|
|
< VERIFY_CHECK(ctx != NULL);
|
|
|
|
< secp256k1_scratch_destroy(&ctx->error_callback, scratch);
|