Skip to content

Commit 856f880

Browse files
Rename _prealloc functions to _preallocated
1 parent 864da3a commit 856f880

File tree

10 files changed

+89
-89
lines changed

10 files changed

+89
-89
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ else
88
JNI_LIB =
99
endif
1010
include_HEADERS = include/secp256k1.h
11-
include_HEADERS += include/secp256k1_prealloc.h
11+
include_HEADERS += include/secp256k1_preallocated.h
1212
noinst_HEADERS =
1313
noinst_HEADERS += src/scalar.h
1414
noinst_HEADERS += src/scalar_4x64.h
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef SECP256K1_PREALLOC_H
2-
#define SECP256K1_PREALLOC_H
1+
#ifndef SECP256K1_PREALLOCACTED_H
2+
#define SECP256K1_PREALLOCACTED_H
33

44
#include "secp256k1.h"
55

@@ -11,27 +11,27 @@ extern "C" {
1111
* caller-provided memory.
1212
*
1313
* The purpose of this function is to determine how much memory must be provided
14-
* to secp256k1_context_prealloc_create.
14+
* to secp256k1_context_preallocated_create.
1515
*
1616
* Returns: the required size of the caller-provided memory block
1717
* In: flags: which parts of the context to initialize.
1818
*/
19-
SECP256K1_API size_t secp256k1_context_prealloc_size(
19+
SECP256K1_API size_t secp256k1_context_preallocated_size(
2020
unsigned int flags
2121
) SECP256K1_WARN_UNUSED_RESULT;
2222

2323
/** Create a secp256k1 context object in caller-provided memory.
2424
*
2525
* Returns: a newly created context object.
2626
* In: prealloc: a pointer to a rewritable contiguous block of memory of
27-
* size at least secp256k1_context_prealloc_size(flags)
27+
* size at least secp256k1_context_preallocated_size(flags)
2828
* bytes, suitably aligned to hold an object of any type
2929
* (cannot be NULL)
3030
* flags: which parts of the context to initialize.
3131
*
3232
* See also secp256k1_context_randomize.
3333
*/
34-
SECP256K1_API secp256k1_context* secp256k1_context_prealloc_create(
34+
SECP256K1_API secp256k1_context* secp256k1_context_preallocated_create(
3535
void* prealloc,
3636
unsigned int flags
3737
) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT;
@@ -40,12 +40,12 @@ SECP256K1_API secp256k1_context* secp256k1_context_prealloc_create(
4040
* caller-provided memory.
4141
*
4242
* The purpose of this function is to determine how much memory must be provided
43-
* to secp256k1_context_prealloc_clone when copying the context ctx.
43+
* to secp256k1_context_preallocated_clone when copying the context ctx.
4444
*
4545
* Returns: the required size of the caller-provided memory block.
4646
* In: ctx: an existing context to copy (cannot be NULL)
4747
*/
48-
SECP256K1_API size_t secp256k1_context_prealloc_clone_size(
48+
SECP256K1_API size_t secp256k1_context_preallocated_clone_size(
4949
const secp256k1_context* ctx
5050
) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT;
5151

@@ -54,11 +54,11 @@ SECP256K1_API size_t secp256k1_context_prealloc_clone_size(
5454
* Returns: a newly created context object.
5555
* Args: ctx: an existing context to copy (cannot be NULL)
5656
* In: prealloc: a pointer to a rewritable contiguous block of memory of
57-
* size at least secp256k1_context_prealloc_size(flags)
57+
* size at least secp256k1_context_preallocated_size(flags)
5858
* bytes, suitably aligned to hold an object of any type
5959
* (cannot be NULL)
6060
*/
61-
SECP256K1_API secp256k1_context* secp256k1_context_prealloc_clone(
61+
SECP256K1_API secp256k1_context* secp256k1_context_preallocated_clone(
6262
const secp256k1_context* ctx,
6363
void* prealloc
6464
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_WARN_UNUSED_RESULT;
@@ -69,21 +69,21 @@ SECP256K1_API secp256k1_context* secp256k1_context_prealloc_clone(
6969
* The context pointer may not be used afterwards.
7070
*
7171
* The context to destroy must have been created using
72-
* secp256k1_context_prealloc_create or secp256k1_context_prealloc_clone.
72+
* secp256k1_context_preallocated_create or secp256k1_context_preallocated_clone.
7373
* If the context has instead been created using secp256k1_context_create or
7474
* secp256k1_context_clone, the behaviour is undefined. In that case,
7575
* secp256k1_context_destroy must be used instead.
7676
*
7777
* Args: ctx: an existing context to destroy, constructed using
78-
* secp256k1_context_prealloc_create or
79-
* secp256k1_context_prealloc_clone (cannot be NULL)
78+
* secp256k1_context_preallocated_create or
79+
* secp256k1_context_preallocated_clone (cannot be NULL)
8080
*/
81-
SECP256K1_API void secp256k1_context_prealloc_destroy(
81+
SECP256K1_API void secp256k1_context_preallocated_destroy(
8282
secp256k1_context* ctx
8383
);
8484

8585
#ifdef __cplusplus
8686
}
8787
#endif
8888

89-
#endif /* SECP256K1_PREALLOC_H */
89+
#endif /* SECP256K1_PREALLOCATED_H */

src/ecmult.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typedef struct {
2020
#endif
2121
} secp256k1_ecmult_context;
2222

23-
static size_t secp256k1_ecmult_context_prealloc_size(void);
23+
static size_t secp256k1_ecmult_context_preallocated_size(void);
2424
static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx);
2525
static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, void **prealloc);
2626
static void secp256k1_ecmult_context_finalize_memcpy(secp256k1_ecmult_context *dst, const secp256k1_ecmult_context *src);

src/ecmult_gen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct {
2828
secp256k1_gej initial;
2929
} secp256k1_ecmult_gen_context;
3030

31-
static size_t secp256k1_ecmult_gen_context_prealloc_size(void);
31+
static size_t secp256k1_ecmult_gen_context_preallocated_size(void);
3232
static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context* ctx);
3333
static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context* ctx, void **prealloc);
3434
static void secp256k1_ecmult_gen_context_finalize_memcpy(secp256k1_ecmult_gen_context *dst, const secp256k1_ecmult_gen_context* src);

src/ecmult_gen_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "ecmult_static_context.h"
1717
#endif
1818

19-
static size_t secp256k1_ecmult_gen_context_prealloc_size(void) {
19+
static size_t secp256k1_ecmult_gen_context_preallocated_size(void) {
2020
#ifndef USE_ECMULT_STATIC_PRECOMPUTATION
2121
return ROUND_TO_ALIGN(sizeof(*((secp256k1_ecmult_gen_context*) NULL)->prec));
2222
#else
@@ -34,15 +34,15 @@ static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context *ctx
3434
secp256k1_gej gj;
3535
secp256k1_gej nums_gej;
3636
int i, j;
37-
size_t const prealloc_size = secp256k1_ecmult_gen_context_prealloc_size();
37+
size_t const prealloc_size = secp256k1_ecmult_gen_context_preallocated_size();
3838
void* const base = *prealloc;
3939
#endif
4040

4141
if (ctx->prec != NULL) {
4242
return;
4343
}
4444
#ifndef USE_ECMULT_STATIC_PRECOMPUTATION
45-
ctx->prec = (secp256k1_ge_storage (*)[64][16])manual_alloc(prealloc, prealloc_size, base, prealloc_size);
45+
ctx->prec = (secp256k1_ge_storage (*)[64][16])manual_malloc(prealloc, prealloc_size, base, prealloc_size);
4646

4747
/* get the generator */
4848
secp256k1_gej_set_ge(&gj, &secp256k1_ge_const_g);

src/ecmult_impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static void secp256k1_ecmult_odd_multiples_table_storage_var(const int n, secp25
254254
} \
255255
} while(0)
256256

257-
static size_t secp256k1_ecmult_context_prealloc_size(void) {
257+
static size_t secp256k1_ecmult_context_preallocated_size(void) {
258258
int ret = ROUND_TO_ALIGN(sizeof((*((secp256k1_ecmult_context*) NULL)->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G));
259259
#ifdef USE_ENDOMORPHISM
260260
ret += ROUND_TO_ALIGN(sizeof((*((secp256k1_ecmult_context*) NULL)->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G));
@@ -272,7 +272,7 @@ static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx) {
272272
static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, void **prealloc) {
273273
secp256k1_gej gj;
274274
void* const base = *prealloc;
275-
size_t const prealloc_size = secp256k1_ecmult_context_prealloc_size();
275+
size_t const prealloc_size = secp256k1_ecmult_context_preallocated_size();
276276

277277
if (ctx->pre_g != NULL) {
278278
return;
@@ -281,7 +281,7 @@ static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, void *
281281
/* get the generator */
282282
secp256k1_gej_set_ge(&gj, &secp256k1_ge_const_g);
283283

284-
ctx->pre_g = (secp256k1_ge_storage (*)[])manual_alloc(prealloc, sizeof((*ctx->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G), base, prealloc_size);
284+
ctx->pre_g = (secp256k1_ge_storage (*)[])manual_malloc(prealloc, sizeof((*ctx->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G), base, prealloc_size);
285285

286286
/* precompute the tables with odd multiples */
287287
secp256k1_ecmult_odd_multiples_table_storage_var(ECMULT_TABLE_SIZE(WINDOW_G), *ctx->pre_g, &gj);
@@ -291,7 +291,7 @@ static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, void *
291291
secp256k1_gej g_128j;
292292
int i;
293293

294-
ctx->pre_g_128 = (secp256k1_ge_storage (*)[])manual_alloc(prealloc, sizeof((*ctx->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G), base, prealloc_size);
294+
ctx->pre_g_128 = (secp256k1_ge_storage (*)[])manual_malloc(prealloc, sizeof((*ctx->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G), base, prealloc_size);
295295

296296
/* calculate 2^128*generator */
297297
g_128j = gj;

src/gen_context.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int main(int argc, char **argv) {
4747
fprintf(fp, "#define SC SECP256K1_GE_STORAGE_CONST\n");
4848
fprintf(fp, "static const secp256k1_ge_storage secp256k1_ecmult_static_context[64][16] = {\n");
4949

50-
base = checked_malloc(&default_error_callback, secp256k1_ecmult_gen_context_prealloc_size());
50+
base = checked_malloc(&default_error_callback, secp256k1_ecmult_gen_context_preallocated_size());
5151
prealloc = base;
5252
secp256k1_ecmult_gen_context_init(&ctx);
5353
secp256k1_ecmult_gen_context_build(&ctx, &prealloc);
@@ -70,10 +70,10 @@ int main(int argc, char **argv) {
7070
fprintf(fp,"};\n");
7171
secp256k1_ecmult_gen_context_clear(&ctx);
7272
free(base);
73-
73+
7474
fprintf(fp, "#undef SC\n");
7575
fprintf(fp, "#endif\n");
7676
fclose(fp);
77-
77+
7878
return 0;
7979
}

src/secp256k1.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**********************************************************************/
66

77
#include "include/secp256k1.h"
8-
#include "include/secp256k1_prealloc.h"
8+
#include "include/secp256k1_preallocated.h"
99

1010
#include "util.h"
1111
#include "num_impl.h"
@@ -65,7 +65,7 @@ static secp256k1_context secp256k1_context_no_precomp_ = {
6565
};
6666
secp256k1_context *secp256k1_context_no_precomp = &secp256k1_context_no_precomp_;
6767

68-
size_t secp256k1_context_prealloc_size(unsigned int flags) {
68+
size_t secp256k1_context_preallocated_size(unsigned int flags) {
6969
size_t ret = ROUND_TO_ALIGN(sizeof(secp256k1_context));
7070

7171
if (EXPECT((flags & SECP256K1_FLAGS_TYPE_MASK) != SECP256K1_FLAGS_TYPE_CONTEXT, 0)) {
@@ -76,34 +76,34 @@ size_t secp256k1_context_prealloc_size(unsigned int flags) {
7676
}
7777

7878
if (flags & SECP256K1_FLAGS_BIT_CONTEXT_SIGN) {
79-
ret += secp256k1_ecmult_gen_context_prealloc_size();
79+
ret += secp256k1_ecmult_gen_context_preallocated_size();
8080
}
8181
if (flags & SECP256K1_FLAGS_BIT_CONTEXT_VERIFY) {
82-
ret += secp256k1_ecmult_context_prealloc_size();
82+
ret += secp256k1_ecmult_context_preallocated_size();
8383
}
8484
return ret;
8585
}
8686

87-
size_t secp256k1_context_prealloc_size_for_clone(const secp256k1_context* ctx) {
87+
size_t secp256k1_context_preallocated_size_for_clone(const secp256k1_context* ctx) {
8888
size_t ret = ROUND_TO_ALIGN(sizeof(secp256k1_context));
8989
VERIFY_CHECK(ctx != NULL);
9090
if (secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)) {
91-
ret += secp256k1_ecmult_gen_context_prealloc_size();
91+
ret += secp256k1_ecmult_gen_context_preallocated_size();
9292
}
9393
if (secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)) {
94-
ret += secp256k1_ecmult_context_prealloc_size();
94+
ret += secp256k1_ecmult_context_preallocated_size();
9595
}
9696
return ret;
9797
}
9898

99-
secp256k1_context* secp256k1_context_prealloc_create(void* prealloc, unsigned int flags) {
99+
secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigned int flags) {
100100
void* const base = prealloc;
101101
size_t prealloc_size;
102102
secp256k1_context* ret;
103103

104104
VERIFY_CHECK(prealloc != NULL);
105-
prealloc_size = secp256k1_context_prealloc_size(flags);
106-
ret = (secp256k1_context*)manual_alloc(&prealloc, sizeof(secp256k1_context), base, prealloc_size);
105+
prealloc_size = secp256k1_context_preallocated_size(flags);
106+
ret = (secp256k1_context*)manual_malloc(&prealloc, sizeof(secp256k1_context), base, prealloc_size);
107107
ret->illegal_callback = default_illegal_callback;
108108
ret->error_callback = default_error_callback;
109109

@@ -128,23 +128,23 @@ secp256k1_context* secp256k1_context_prealloc_create(void* prealloc, unsigned in
128128
}
129129

130130
secp256k1_context* secp256k1_context_create(unsigned int flags) {
131-
size_t const prealloc_size = secp256k1_context_prealloc_size(flags);
131+
size_t const prealloc_size = secp256k1_context_preallocated_size(flags);
132132
secp256k1_context* ctx = (secp256k1_context*)checked_malloc(&default_error_callback, prealloc_size);
133-
if (EXPECT(secp256k1_context_prealloc_create(ctx, flags) == NULL, 0)) {
133+
if (EXPECT(secp256k1_context_preallocated_create(ctx, flags) == NULL, 0)) {
134134
free(ctx);
135135
return NULL;
136136
}
137137

138138
return ctx;
139139
}
140140

141-
secp256k1_context* secp256k1_context_prealloc_clone(const secp256k1_context* ctx, void* prealloc) {
141+
secp256k1_context* secp256k1_context_preallocated_clone(const secp256k1_context* ctx, void* prealloc) {
142142
size_t prealloc_size;
143143
secp256k1_context* ret;
144144
VERIFY_CHECK(ctx != NULL);
145145
ARG_CHECK(prealloc != NULL);
146146

147-
prealloc_size = secp256k1_context_prealloc_size_for_clone(ctx);
147+
prealloc_size = secp256k1_context_preallocated_size_for_clone(ctx);
148148
ret = (secp256k1_context*)prealloc;
149149
memcpy(ret, ctx, prealloc_size);
150150
secp256k1_ecmult_gen_context_finalize_memcpy(&ret->ecmult_gen_ctx, &ctx->ecmult_gen_ctx);
@@ -157,13 +157,13 @@ secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
157157
size_t prealloc_size;
158158

159159
VERIFY_CHECK(ctx != NULL);
160-
prealloc_size = secp256k1_context_prealloc_size_for_clone(ctx);
160+
prealloc_size = secp256k1_context_preallocated_size_for_clone(ctx);
161161
ret = (secp256k1_context*)checked_malloc(&ctx->error_callback, prealloc_size);
162-
ret = secp256k1_context_prealloc_clone(ctx, ret);
162+
ret = secp256k1_context_preallocated_clone(ctx, ret);
163163
return ret;
164164
}
165165

166-
void secp256k1_context_prealloc_destroy(secp256k1_context* ctx) {
166+
void secp256k1_context_preallocated_destroy(secp256k1_context* ctx) {
167167
if (ctx != NULL) {
168168
secp256k1_ecmult_context_clear(&ctx->ecmult_ctx);
169169
secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);
@@ -172,7 +172,7 @@ void secp256k1_context_prealloc_destroy(secp256k1_context* ctx) {
172172

173173
void secp256k1_context_destroy(secp256k1_context* ctx) {
174174
if (ctx != NULL) {
175-
secp256k1_context_prealloc_destroy(ctx);
175+
secp256k1_context_preallocated_destroy(ctx);
176176
free(ctx);
177177
}
178178
}

0 commit comments

Comments
 (0)