Compare commits

..

2 Commits

2 changed files with 13 additions and 0 deletions

View File

@@ -13,6 +13,8 @@ extern "C" {
Design goal: easy to use in tools, easy to test, portable across Linux/macOS. Design goal: easy to use in tools, easy to test, portable across Linux/macOS.
*/ */
//#define ENABLE_NICKEL_ALLOC_SHIM
typedef struct ni_alloc_stats { typedef struct ni_alloc_stats {
/* current usage */ /* current usage */
size_t bytes_in_use; /* user-visible allocated bytes (approx if desired) */ size_t bytes_in_use; /* user-visible allocated bytes (approx if desired) */
@@ -115,6 +117,17 @@ size_t ni_align_up(size_t x, size_t align);
*/ */
bool ni_alloc_validate(void); bool ni_alloc_validate(void);
#ifdef ENABLE_NICKEL_ALLOC_SHIM
/* Allocation functions using the global allocator.
define symbols pointing at our versions
*/
void* malloc(size_t size) { ni_malloc(size); }
void free(void* ptr) { ni_free(ptr); }
void* realloc(void* ptr, size_t new_size) { ni_realloc(ptr, new_size); }
void* calloc(size_t count, size_t elem_size) { ni_calloc(count, elem_size); }
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif