just another example
[fw/sdcc] / src / SDCCalloc.h
1
2 #ifndef _SDCCalloc_H
3 #define _SDCCalloc_H
4
5 #include "SDCCerr.h"
6
7 #if OPT_DISABLE_GC != 0
8
9 # include <malloc.h>
10 # define GC_malloc(x) calloc((x), 1)
11 # define GC_free(x)   free(x)
12 # define GC_realloc   realloc
13 # define GC_malloc_atomic malloc
14
15 #else
16
17 #include "./gc/gc.h" 
18
19 #endif
20
21
22 #define  ALLOC(x,sz) if (!(x = GC_malloc(sz)))      \
23          {                                          \
24             werror(E_OUT_OF_MEM,__FILE__,(long) sz);\
25             exit (1);                               \
26          }
27
28 #define ALLOC_ATOMIC(x,sz)   if (!(x = GC_malloc_atomic(sz)))   \
29          {                                               \
30             werror(E_OUT_OF_MEM,__FILE__,(long) sz);     \
31             exit (1);                                    \
32          }
33
34
35 #endif