Skip to content

Commit 53796d2

Browse files
contexts: Rename static context
1 parent 72fedf8 commit 53796d2

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

doc/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Each change falls into one of the following categories: Added, Changed, Deprecat
1111

1212
### Deprecated
1313
- Deprecated context flags `SECP256K1_CONTEXT_VERIFY` and `SECP256K1_CONTEXT_SIGN`. Use `SECP256K1_CONTEXT_NONE` instead.
14+
- Renamed `secp256k1_context_no_precomp` to `secp256k1_context_static`.
1415

1516
## [MAJOR.MINOR.PATCH] - YYYY-MM-DD
1617

include/secp256k1.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,17 @@ typedef int (*secp256k1_nonce_function)(
222222
* it is mentioned in its documentation. See secp256k1_context_create if you need a
223223
* full context object that supports all functionality offered by the library.
224224
*/
225-
SECP256K1_API extern const secp256k1_context *secp256k1_context_no_precomp;
225+
SECP256K1_API extern const secp256k1_context *secp256k1_context_static;
226+
227+
/** Deprecated alias for secp256k1_context_static. */
228+
SECP256K1_API extern const secp256k1_context *secp256k1_context_no_precomp
229+
SECP256K1_DEPRECATED("Use secp256k1_context_static instead");
226230

227231
/** Create a secp256k1 context object (in dynamically allocated memory).
228232
*
229233
* This function uses malloc to allocate memory. It is guaranteed that malloc is
230234
* called at most once for every call of this function. If you need to avoid dynamic
231-
* memory allocation entirely, see secp256k1_context_no_precomp and the functions in
235+
* memory allocation entirely, see secp256k1_context_static and the functions in
232236
* secp256k1_preallocated.h.
233237
*
234238
* Returns: a newly created context object.

src/secp256k1.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ struct secp256k1_context_struct {
6464
int declassify;
6565
};
6666

67-
static const secp256k1_context secp256k1_context_no_precomp_ = {
67+
static const secp256k1_context secp256k1_context_static_ = {
6868
{ 0 },
6969
{ secp256k1_default_illegal_callback_fn, 0 },
7070
{ secp256k1_default_error_callback_fn, 0 },
7171
0
7272
};
73-
const secp256k1_context *secp256k1_context_no_precomp = &secp256k1_context_no_precomp_;
73+
const secp256k1_context *secp256k1_context_static = &secp256k1_context_static_;
74+
const secp256k1_context *secp256k1_context_no_precomp = &secp256k1_context_static_;
7475

7576
size_t secp256k1_context_preallocated_size(unsigned int flags) {
7677
size_t ret = sizeof(secp256k1_context);
@@ -150,7 +151,7 @@ secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
150151
}
151152

152153
void secp256k1_context_preallocated_destroy(secp256k1_context* ctx) {
153-
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_no_precomp);
154+
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_static);
154155
if (ctx != NULL) {
155156
secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);
156157
}
@@ -164,7 +165,7 @@ void secp256k1_context_destroy(secp256k1_context* ctx) {
164165
}
165166

166167
void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
167-
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_no_precomp);
168+
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_static);
168169
if (fun == NULL) {
169170
fun = secp256k1_default_illegal_callback_fn;
170171
}
@@ -173,7 +174,7 @@ void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(
173174
}
174175

175176
void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
176-
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_no_precomp);
177+
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_static);
177178
if (fun == NULL) {
178179
fun = secp256k1_default_error_callback_fn;
179180
}

src/tests.c

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ void run_context_tests(int use_prealloc) {
164164
secp256k1_scalar msg, key, nonce;
165165
secp256k1_scalar sigr, sigs;
166166

167+
/* Check that deprecated secp256k1_context_no_precomp is an alias to secp256k1_context_static. */
168+
CHECK(secp256k1_context_no_precomp == secp256k1_context_static);
169+
167170
if (use_prealloc) {
168171
none_prealloc = malloc(secp256k1_context_preallocated_size(SECP256K1_CONTEXT_NONE));
169172
sign_prealloc = malloc(secp256k1_context_preallocated_size(SECP256K1_CONTEXT_SIGN));

0 commit comments

Comments
 (0)