diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-03-17 23:16:21 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-03-17 23:16:21 +0100 |
commit | 012f9e4156919157bfff0d5ce8f105a04b0c4a70 (patch) | |
tree | cacce5438a0e6fa8baef4ee4ef96951d7b1dd8a4 /client/memory.h | |
parent | add6b39aece179a0e0ad425af72b8a043a0d3188 (diff) |
client: Start working on a simple client
Diffstat (limited to 'client/memory.h')
-rw-r--r-- | client/memory.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/client/memory.h b/client/memory.h new file mode 100644 index 0000000..19cfb95 --- /dev/null +++ b/client/memory.h @@ -0,0 +1,15 @@ +#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)))) +#define strdup(str) \ + ((char*)check_after_allocation_str("strdup",strdup(str))) + +void* check_after_allocation(const char *func,size_t num,size_t sz,void *ptr); +void* check_after_allocation_str(const char *func,void *ptr); |