Skip to content

Commit a7a164f

Browse files
committed
scratch: rename max_size to size, document that extra will actually be allocated
1 parent 5a4bc0b commit a7a164f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

include/secp256k1.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,12 @@ SECP256K1_API void secp256k1_context_set_error_callback(
285285
*
286286
* Returns: a newly created scratch space.
287287
* Args: ctx: an existing context object (cannot be NULL)
288-
* In: max_size: maximum amount of memory to allocate
288+
* In: size: amount of memory to be available as scratch space. Some extra
289+
* (<100 bytes) will be allocated for extra accounting.
289290
*/
290291
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT secp256k1_scratch_space* secp256k1_scratch_space_create(
291292
const secp256k1_context* ctx,
292-
size_t max_size
293+
size_t size
293294
) SECP256K1_ARG_NONNULL(1);
294295

295296
/** Destroy a secp256k1 scratch space.

src/scratch_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
#include "util.h"
1111
#include "scratch.h"
1212

13-
static secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* error_callback, size_t max_size) {
13+
static secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* error_callback, size_t size) {
1414
const size_t base_alloc = ((sizeof(secp256k1_scratch) + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT;
15-
void *alloc = checked_malloc(error_callback, base_alloc + max_size);
15+
void *alloc = checked_malloc(error_callback, base_alloc + size);
1616
secp256k1_scratch* ret = (secp256k1_scratch *)alloc;
1717
if (ret != NULL) {
1818
memset(ret, 0, sizeof(*ret));
1919
memcpy(ret->magic, "scratch", 8);
2020
ret->data = (void *) ((char *) alloc + base_alloc);
21-
ret->max_size = max_size;
21+
ret->max_size = size;
2222
}
2323
return ret;
2424
}

0 commit comments

Comments
 (0)