diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-01-18 22:16:55 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-01-18 22:16:55 +0100 |
commit | 6b260962eef4caa486ceee9a60b61c67269025c6 (patch) | |
tree | dacf3dfd87d440f998eab8e486996e12132aef01 /memory.h |
Initial
Diffstat (limited to 'memory.h')
-rw-r--r-- | memory.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/memory.h b/memory.h new file mode 100644 index 0000000..6fcb7e1 --- /dev/null +++ b/memory.h @@ -0,0 +1,16 @@ +#pragma once + +#include <stdlib.h> +#include <string.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)))) +#define strdup(str) \ + ((char*)check_after_allocation("strdup", strdup(str))) + +void* check_after_allocation(const char *funcname, void *ptr); |