-
Notifications
You must be signed in to change notification settings - Fork 0
/
mem.h
27 lines (20 loc) · 842 Bytes
/
mem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef MEM_INCLUDED
#define MEM_INCLUDED
#include "except.h"
#include <stdint.h>
extern const Except_T Mem_Failed;
extern void* Mem_alloc(long nbytes, const char *file, int32_t line);
extern void* Mem_calloc(long count, long nbytes, const char *file, int32_t line);
extern void Mem_free(void* ptr, const char *file, int32_t line);
extern void *Mem_resize(void* ptr,long nbytes,const char* file, int32_t line);
#define ALLOC(nbytes)\
Mem_alloc((nbytes), __FILE__, __LINE__)
#define CALLOC(count, nbytes)\
Mem_calloc((count), (nbytes), __FILE__, __LINE__)
#define FREE(ptr) ((void)(Mem_free((ptr), \
__FILE__, __LINE__), (ptr) = 0 ))
#define RESIZE(ptr,nbytes) ((ptr)=Mem_resize((ptr), \
(nbytes),__FILE__,__LINE__))
#define NEW(p) ((p)=ALLOC((long)sizeof *(p)))
#define NEWO(p) ((p)=CALLOC(1,(long)sizeof *(p)))
#endif