]> git.draconx.ca Git - cdecl99.git/blobdiff - src/cdecl-internal.h
libcdecl: Actually test threading support.
[cdecl99.git] / src / cdecl-internal.h
index dc8d1f0642780d80b7d678ad40cffa38b61acb90..335094c47511d7629564591a963dcc85d7a71a27 100644 (file)
@@ -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