From 54064158d84fc4006e651deb314cde156cc383e8 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Tue, 14 Mar 2017 11:05:35 +0100 Subject: Register working --- memory.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 memory.h (limited to 'memory.h') diff --git a/memory.h b/memory.h new file mode 100644 index 0000000..970648f --- /dev/null +++ b/memory.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +#define malloc(num,type) \ + ((type*)check_after_allocation("malloc",num,sizeof(type),malloc((num)*sizeof(type)))) +#define calloc(num,type) \ + ((type*)check_after_allocation("calloc",num,sizeof(type),calloc((num),sizeof(type)))) +#define realloc(ptr,num,type) \ + ((type*)check_after_allocation("realloc",num,sizeof(type),realloc((ptr),(num)*sizeof(type)))) + +void* check_after_allocation(const char *func,size_t num,size_t sz,void *ptr); -- cgit v1.2.3-54-g00ecf