Bitcoin Core  0.20.99
P2P Digital Currency
scratch.h
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright (c) 2017 Andrew Poelstra *
3  * Distributed under the MIT software license, see the accompanying *
4  * file COPYING or http://www.opensource.org/licenses/mit-license.php.*
5  **********************************************************************/
6 
7 #ifndef _SECP256K1_SCRATCH_
8 #define _SECP256K1_SCRATCH_
9 
10 #define SECP256K1_SCRATCH_MAX_FRAMES 5
11 
12 /* The typedef is used internally; the struct name is used in the public API
13  * (where it is exposed as a different typedef) */
18  size_t frame;
19  size_t max_size;
22 
24 
25 static void secp256k1_scratch_destroy(secp256k1_scratch* scratch);
26 
28 static int secp256k1_scratch_allocate_frame(secp256k1_scratch* scratch, size_t n, size_t objects);
29 
32 
34 static size_t secp256k1_scratch_max_allocation(const secp256k1_scratch* scratch, size_t n_objects);
35 
37 static void *secp256k1_scratch_alloc(secp256k1_scratch* scratch, size_t n);
38 
39 #endif
void * data[SECP256K1_SCRATCH_MAX_FRAMES]
Definition: scratch.h:15
const secp256k1_callback * error_callback
Definition: scratch.h:20
struct secp256k1_scratch_space_struct secp256k1_scratch
static void secp256k1_scratch_destroy(secp256k1_scratch *scratch)
#define SECP256K1_SCRATCH_MAX_FRAMES
Definition: scratch.h:10
size_t frame_size[SECP256K1_SCRATCH_MAX_FRAMES]
Definition: scratch.h:17
static void secp256k1_scratch_deallocate_frame(secp256k1_scratch *scratch)
Deallocates a stack frame.
static int secp256k1_scratch_allocate_frame(secp256k1_scratch *scratch, size_t n, size_t objects)
Attempts to allocate a new stack frame with n available bytes.
static size_t secp256k1_scratch_max_allocation(const secp256k1_scratch *scratch, size_t n_objects)
Returns the maximum allocation the scratch space will allow.
static void * secp256k1_scratch_alloc(secp256k1_scratch *scratch, size_t n)
Returns a pointer into the most recently allocated frame, or NULL if there is insufficient available ...
static secp256k1_scratch * secp256k1_scratch_create(const secp256k1_callback *error_callback, size_t max_size)
size_t offset[SECP256K1_SCRATCH_MAX_FRAMES]
Definition: scratch.h:16