support for memory allocation
authorstevewilliams <stevewilliams@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 5 Nov 2000 17:51:13 +0000 (17:51 +0000)
committerstevewilliams <stevewilliams@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 5 Nov 2000 17:51:13 +0000 (17:51 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@486 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCalloc.h [new file with mode: 0644]

diff --git a/src/SDCCalloc.h b/src/SDCCalloc.h
new file mode 100644 (file)
index 0000000..2ffe5ec
--- /dev/null
@@ -0,0 +1,35 @@
+
+#ifndef _SDCCalloc_H
+#define _SDCCalloc_H
+
+#include "SDCCerr.h"
+
+#ifdef OPT_DISABLE_GC
+
+# include <malloc.h>
+# 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