]> git.draconx.ca Git - cdecl99.git/blobdiff - src/cdecl-internal.h
Port to use getline.h from dxcommon.
[cdecl99.git] / src / cdecl-internal.h
index b586dd45e5b00b7c08d2da83b211cce8f3556293..335094c47511d7629564591a963dcc85d7a71a27 100644 (file)
@@ -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