summaryrefslogtreecommitdiff
path: root/memory.h
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-12-25 10:14:11 +0100
committertomsmeding <tom.smeding@gmail.com>2016-12-25 10:14:11 +0100
commitef28fcb0f59d11bdf9f574a999045bc24ca40e18 (patch)
tree5e998366f3ef2f2be88216d28631656c84036e41 /memory.h
Initial
Diffstat (limited to 'memory.h')
-rw-r--r--memory.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/memory.h b/memory.h
new file mode 100644
index 0000000..076261d
--- /dev/null
+++ b/memory.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <stdlib.h>
+
+
+#define malloc(num, type) \
+ ((type*)check_after_allocation("malloc", malloc((num)*sizeof(type))))
+#define calloc(num, type) \
+ ((type*)check_after_allocation("calloc", calloc((num), sizeof(type))))
+#define realloc(ptr, num, type) \
+ ((type*)check_after_allocation("realloc", realloc(ptr, (num)*sizeof(type))))
+
+void* check_after_allocation(const char *funcname, void *ptr);