aboutsummaryrefslogtreecommitdiff
path: root/memory.h
blob: 970648fd80042657ef7c8f2b41dd2d24463f9123 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#pragma once

#include <stdlib.h>

#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);