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

27 lines
1.0 KiB
Diff

13,37d12
< static secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* error_callback, size_t size) {
< 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) {
< VERIFY_CHECK(scratch->alloc_size == 0); /* all checkpoints should be applied */
< if (memcmp(scratch->magic, "scratch", 8) != 0) {
< secp256k1_callback_call(error_callback, "invalid scratch space");
< return;
< }
< memset(scratch->magic, 0, sizeof(scratch->magic));
< free(scratch);
< }
< }
<