diff options
Diffstat (limited to 'memory.h')
-rw-r--r-- | memory.h | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -3,6 +3,10 @@ #include <stdlib.h> #include <string.h> +void* memdup(void *buf, size_t num); + +void* check_after_allocation(const char *funcname, void *ptr); + #define malloc(num, type) \ ((type*)check_after_allocation("malloc", malloc((num)*sizeof(type)))) @@ -11,6 +15,6 @@ #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); + ((char*)check_after_allocation("strdup", strdup((str)))) +#define memdup(buf, num) \ + ((char*)check_after_allocation("memdup", memdup((void*)(buf), (num)))) |