summaryrefslogtreecommitdiff
path: root/src/alloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.h')
-rw-r--r--src/alloc.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/alloc.h b/src/alloc.h
new file mode 100644
index 0000000..0a09a30
--- /dev/null
+++ b/src/alloc.h
@@ -0,0 +1,27 @@
+//
+// Created by Anshul Gupta on 4/9/25.
+//
+
+#ifndef ALLOC_H
+#define ALLOC_H
+
+#ifdef TEST_ALLOC
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <cmocka.h>
+#define gmalloc(size) test_malloc(size)
+#define gcalloc(num, size) test_calloc(num, size)
+#define grealloc(ptr, size) test_realloc(ptr, size)
+#define gfree(ptr) test_free(ptr)
+#else
+#include <stdlib.h>
+#define gmalloc(size) malloc(size)
+#define gcalloc(num, size) calloc(num, size)
+#define grealloc(ptr, size) realloc(ptr, size)
+#define gfree(ptr) free(ptr)
+#endif
+
+#endif // ALLOC_H