X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/e9d3a59c29b3eea45ea37bc3ceef5d32ed81b9eb..c11f668ec9c5b2f0016cf6920a111c52e895b24a:/src/cdecl-internal.h diff --git a/src/cdecl-internal.h b/src/cdecl-internal.h index b586dd4..335094c 100644 --- a/src/cdecl-internal.h +++ b/src/cdecl-internal.h @@ -83,7 +83,7 @@ struct output_state { size_t cdecl__advance(struct output_state *dst, size_t amount); size_t cdecl__emit(struct output_state *dst, const char *src); -size_t cdecl__emit_uint(struct output_state *dst, uintmax_t val); +size_t cdecl__emit_uint(struct output_state *dst, cdecl_uintmax val); size_t cdecl__strlcpy(char *dst, const char *src, size_t len); const char *cdecl__emit_specs(struct output_state *dst, @@ -134,4 +134,28 @@ struct parse_item *cdecl__alloc_item(size_t s_sz); # endif #endif +/* + * Build-time hook for white-box testing of memory allocation behaviour. + */ +#if TEST_MALLOC_HOOK +void *test_realloc_hook(void *, size_t); + +static inline void *test_wrap_malloc(size_t n) +{ + return test_realloc_hook(0, n); +} + +static inline void test_wrap_free(void *p) +{ + test_realloc_hook(p, 0); +} + +#undef realloc +#define realloc test_realloc_hook +#undef malloc +#define malloc test_wrap_malloc +#undef free +#define free test_wrap_free +#endif + #endif