From cc67c6427d1696948e88d79ec3fb8c6871ba312a Mon Sep 17 00:00:00 2001 From: stevewilliams Date: Sun, 5 Nov 2000 17:51:13 +0000 Subject: [PATCH] support for memory allocation git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@486 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCalloc.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/SDCCalloc.h 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 -- 2.47.2