7 #ifndef _SECP256K1_SCRATCH_IMPL_H_
8 #define _SECP256K1_SCRATCH_IMPL_H_
21 memset(ret, 0,
sizeof(*ret));
29 if (scratch != NULL) {
35 static size_t secp256k1_scratch_max_allocation(
const secp256k1_scratch* scratch,
size_t objects) {
38 for (i = 0; i < scratch->
frame; i++) {
47 static int secp256k1_scratch_allocate_frame(
secp256k1_scratch* scratch,
size_t n,
size_t objects) {
50 if (n <= secp256k1_scratch_max_allocation(scratch, objects)) {
53 if (scratch->
data[scratch->
frame] == NULL) {
73 size_t frame = scratch->
frame - 1;
79 ret = (
void *) ((
unsigned char *) scratch->
data[frame] + scratch->
offset[frame]);
81 scratch->
offset[frame] += size;