Skip to content

Commit be5e54c

Browse files
committed
build: avoid exposing internal defines in the amalgamation code
This allows for easier inclusion of the source file directly in an existing projects source, rather than compiling it as a separate file.
1 parent ee8b847 commit be5e54c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/amalgamation/combined.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* config.h (which must be provided by the amalgamation user)
3939
* is included.
4040
*/
41+
#define BUILD_AMALGAMATION 1
4142
#include "src/internal.h"
4243

4344
/* The amalgamation user can provide their own defines and skip
@@ -121,3 +122,10 @@ void wally_silence_unused_warnings(void)
121122
assert_bip38_assumptions();
122123
assert_tx_assumptions();
123124
}
125+
126+
/* Undefine our internal macros */
127+
#undef BYTES_VALID
128+
#undef BYTES_INVALID
129+
#undef BYTES_INVALID_N
130+
#undef OUTPUT_CHECK
131+
#undef OUTPUT_ALLOC

src/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@ bool mem_is_zero(const void *mem, size_t len);
7373
/* Fetch our internal operations function pointers */
7474
const struct wally_operations *wally_ops(void);
7575

76+
#ifndef BUILD_AMALGAMATION
7677
#define malloc(size) __use_wally_malloc_internally__
7778
#define calloc(size) __use_wally_calloc_internally__
7879
#define free(ptr) __use_wally_free_internally__
7980
#ifdef strdup
8081
#undef strdup
8182
#endif
8283
#define strdup(ptr) __use_wally_strdup_internally__
84+
#endif
8385

8486
#define NUM_ELEMS(a) (sizeof(a) / sizeof(a[0]))
8587

0 commit comments

Comments
 (0)