From: stevewilliams Date: Sun, 5 Nov 2000 17:51:13 +0000 (+0000) Subject: support for memory allocation X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=cc67c6427d1696948e88d79ec3fb8c6871ba312a;p=fw%2Fsdcc support for memory allocation git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@486 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCalloc.h b/src/SDCCalloc.h new file mode 100644 index 00000000..2ffe5ec2 --- /dev/null +++ b/src/SDCCalloc.h @@ -0,0 +1,35 @@ + +#ifndef _SDCCalloc_H +#define _SDCCalloc_H + +#include "SDCCerr.h" + +#ifdef OPT_DISABLE_GC + +# include +# define GC_malloc(x) calloc((x), 1) +# define GC_free(x) free(x) +# define GC_realloc realloc +# define GC_malloc_atomic malloc + +#else + +#include "./gc/gc.h" + +#endif + + +#define ALLOC(x,sz) if (!(x = GC_malloc(sz))) \ + { \ + werror(E_OUT_OF_MEM,__FILE__,(long) sz);\ + exit (1); \ + } + +#define ALLOC_ATOMIC(x,sz) if (!(x = GC_malloc_atomic(sz))) \ + { \ + werror(E_OUT_OF_MEM,__FILE__,(long) sz); \ + exit (1); \ + } + + +#endif