commit da5beb0f312268972e26cb09c00eb5ab05beddaf
parent b5e6f0bf3c6c1c0cd060f5a2439ba1ec0060682f
Author: Eyal Sawady <ecs@d2evs.net>
Date: Mon, 28 Dec 2020 10:49:49 -0500
util.h: add malloc macro
To prevent the accidental use of malloc instead of xcalloc
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/include/util.h b/include/util.h
@@ -9,6 +9,7 @@ unsigned long djb2_s(unsigned long hash, const char *str);
void *xcalloc(size_t n, size_t s);
void *xrealloc(void *p, size_t s);
+#define malloc(a) (void *)sizeof(struct { static_assert(0, "Use xcalloc instead"); int _; });
#define calloc(a, b) (void *)sizeof(struct { static_assert(0, "Use xcalloc instead"); int _; });
#define realloc(a, b) (void *)sizeof(struct { static_assert(0, "Use xrealloc instead"); int _; });