]> begriffs open source - libderp/blob - include/internal/alloc.h
WIP: Boehm GC support
[libderp] / include / internal / alloc.h
1 #ifndef DERP_ALLOC_H
2 #define DERP_ALLOC_H
3
4 #ifdef DERP_USE_BOEHM_GC
5
6         #include <gc.h>
7         #undef  internal_malloc
8         #define internal_malloc(n) GC_MALLOC(n)
9         #undef  internal_free
10         #define internal_free(p) GC_FREE(p)
11         #undef  internal_realloc
12         #define internal_realloc(p,n) GC_REALLOC(p,n)
13
14 #elif !defined(internal_malloc) && \
15       !defined(internal_free) && \
16       !defined(internal_realloc)
17
18         /* if not otherwise overridden, use stdlib alloc funcs */
19         #include <stdlib.h>
20         #define internal_malloc(n) malloc(n)
21         #define internal_free(p) free(p)
22         #define internal_realloc(p,n) realloc(p,n)
23
24 #endif
25
26 #endif