rust-secp256k1-unsafe-fast/secp256k1-sys/depend/scratch_impl.h.patch

27 lines
1.1 KiB
Diff
Raw Normal View History

13,37d12
< static secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* error_callback, size_t size) {
2020-09-15 01:39:26 +00:00
< const size_t base_alloc = ROUND_TO_ALIGN(sizeof(secp256k1_scratch));
< void *alloc = checked_malloc(error_callback, base_alloc + size);
< secp256k1_scratch* ret = (secp256k1_scratch *)alloc;
< if (ret != NULL) {
< memset(ret, 0, sizeof(*ret));
< memcpy(ret->magic, "scratch", 8);
< ret->data = (void *) ((char *) alloc + base_alloc);
< ret->max_size = size;
< }
< return ret;
< }
<
< static void secp256k1_scratch_destroy(const secp256k1_callback* error_callback, secp256k1_scratch* scratch) {
< if (scratch != NULL) {
< if (secp256k1_memcmp_var(scratch->magic, "scratch", 8) != 0) {
< secp256k1_callback_call(error_callback, "invalid scratch space");
< return;
< }
< VERIFY_CHECK(scratch->alloc_size == 0); /* all checkpoints should be applied */
< memset(scratch->magic, 0, sizeof(scratch->magic));
< free(scratch);
< }
< }
<