New Memory Allocation functions
authorjtvolpe <jtvolpe@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 4 Feb 2001 15:50:58 +0000 (15:50 +0000)
committerjtvolpe <jtvolpe@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 4 Feb 2001 15:50:58 +0000 (15:50 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@575 4a8a32a2-be11-0410-ad9d-d568d2c75423

83 files changed:
as/as_z80.dsp
as/aslink.dsp
as/asx8051.dsp
as/mcs51/asdata.c
as/mcs51/asexpr.c
as/mcs51/aslex.c
as/mcs51/aslist.c
as/mcs51/asmain.c
as/mcs51/asnoice.c
as/mcs51/asout.c
as/mcs51/asstore.c
as/mcs51/assubr.c
as/mcs51/lkarea.c
as/mcs51/lkdata.c
as/mcs51/lkeval.c
as/mcs51/lkhead.c
as/mcs51/lkihx.c
as/mcs51/lklex.c
as/mcs51/lklibr.c
as/mcs51/lklist.c
as/mcs51/lkmain.c
as/mcs51/lknoice.c
as/mcs51/lkrloc.c
as/mcs51/lks19.c
as/mcs51/lkstore.c
as/z80/alloc.h
as/z80/asdata.c
as/z80/asexpr.c
as/z80/aslex.c
as/z80/aslist.c
as/z80/asmain.c
as/z80/asout.c
as/z80/assubr.c
debugger/mcs51/break.c
debugger/mcs51/sdcdb.c
debugger/mcs51/sdcdb.h
debugger/mcs51/symtab.c
device/lib/printfl.c
link/z80/lklibr.c
packihx/PackIhx.dsp
sdcc_vc.h
src/SDCC.lex
src/SDCC.y
src/SDCCBBlock.c
src/SDCCBBlock.h
src/SDCCast.c
src/SDCCbitv.c
src/SDCCcse.c
src/SDCCglobl.h
src/SDCCglue.c
src/SDCChasht.c
src/SDCCicode.c
src/SDCCloop.c
src/SDCCmain.c
src/SDCCpeeph.c
src/SDCCset.c
src/SDCCsymt.c
src/SDCCval.c
src/avr/avr.dsp
src/avr/gen.c
src/ds390/ds390.dsp
src/ds390/gen.c
src/mcs51/gen.c
src/mcs51/mcs51.dsp
src/mcs51/ralloc.c
src/pic/gen.c
src/pic/glue.c
src/pic/pic.dsp
src/pic/ralloc.c
src/src.dsp
src/z80/gen.c
src/z80/z80.dsp
support/Util/NewAlloc.c [new file with mode: 0644]
support/Util/SDCCerr.h [new file with mode: 0644]
support/Util/newalloc.h [new file with mode: 0644]
support/Util/sdccerr.c [new file with mode: 0644]
support/cpp/config.h
support/cpp/cppalloc.c
support/cpp/cppexp.c
support/cpp/cpphash.c
support/cpp/cpplib.c
support/cpp/cpplib.h
support/cpp/sdcpp.dsp

index 147e7a60a1d68dc11fa2d7cb0acf7bce2e4f9da7..71f3cc4f24c1025c9603d6898b1aee5e981534b7 100644 (file)
@@ -42,8 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /YX /J /FD /c
-# SUBTRACT CPP /WX
+# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -67,8 +66,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /J /FD /GZ /c
-# SUBTRACT CPP /WX /Fr
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /J /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index 8d63976f730a08e0b4a383083477b5b772fe85ae..a9e52e8ba31ac88f85c63c25c4e01b306f9f6f28 100644 (file)
@@ -42,8 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /J /FD /c
-# SUBTRACT CPP /WX
+# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -68,8 +67,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c
-# SUBTRACT CPP /WX
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index 881d4096fc3d2e4d10ab54a36181a4127b3ff631..44096f695d0ebb5d4ca4850d8c84e63bb97d1909 100644 (file)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /WX /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /J /FD /c
+# ADD CPP /nologo /G3 /Zp1 /W3 /WX /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -67,7 +67,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index e49a257b00b33edeef9f2f0c721e24b901b347ff..51f1c37b983d5f4612d5712d224af6cb90055e3a 100644 (file)
@@ -17,9 +17,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "asm.h"
 
 /*)Module      asdata.c
index c648026ee7b9776bc4fb133cfecfa57b480dd4af..5d34b045abe33f16a60d570bc57cc9253098c8c9 100644 (file)
@@ -12,9 +12,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "asm.h"
 
 /*)Module      asexpr.c
index a0af00c61d26c4cc9685f012d974472d4393e333..fcf391007eeacb4f6407aaf9506a2f437b8faf68 100644 (file)
@@ -15,9 +15,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "asm.h"
 
 /*)Module      aslex.c
index 6a6cf7c916e9d02e0243c4122184fa62d12eba99..c8518278d7705738e72496f0e381c26eb0718d83 100644 (file)
@@ -15,9 +15,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include <stdlib.h>
 #include "asm.h"
 
index 9dfe59bc9c3142080001439efeb9594e9b253b20..a2f11db668c9a3a5be70835965386862d21e5262 100644 (file)
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <unistd.h>
-#include <alloc.h>
-#endif
+
+//#if defined(_MSC_VER)
+//#include <stdlib.h>
+//#else          // _MSC_VER
+//#include <alloc.h>
+//#endif         // _MSC_VER
+
 #include "asm.h"
 
 extern VOID machine(struct mne *);
index 4611587cbab6202e3cf8ccbd41dce7ec2082d467..b8de1bb31d2c3f595cb01c2044db70f255fcfbee 100644 (file)
@@ -9,9 +9,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "asm.h"
 
 /* Return basic file name without path or extension */
index c21b4ac285369663aea7027c50960dd54200d2af..54d4bb314e250c7e70047f5c95221b442ec8c800 100644 (file)
@@ -16,9 +16,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "asm.h"
 
 
index 4e3947308216895a5c62200f1b8cd3aa418addb5..8170ff3d77c5ba7277185ce0373910334b9dacd1 100644 (file)
@@ -3,9 +3,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "asm.h"
 
 /*
index 786712e99320b17ca2a3d739cb9c004040fbbdfe..8cabf28ed5d825e7cb6a5167ec659e24f43e8b12 100644 (file)
@@ -12,9 +12,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "asm.h"
 
 /*)Module      assubr.c
index baaa6ac3e3a9ded3312aa44b3ca2d051ea0ea382..29fa00b6a7daef3d603f43d002d5d6fb7c5b12ef 100644 (file)
@@ -15,9 +15,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*)Module      lkarea.c
index ecd9cd3e36f7585036456ffcc07fd26703844037..607b946df762499980a644bcd731478155e83ea2 100644 (file)
@@ -16,9 +16,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*)Module      lkdata.c
index 4834139ef4c926cab29dceff11029df29b444f58..0a980df37291ad8250d6a028e02add252ca3a966 100644 (file)
@@ -11,9 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*)Module      lkeval.c
index fa3105efd8c94851e571e6d169b3bad58e369ff1..898d7fe82d685bb3c2b36fb50e2acf9f59817273 100644 (file)
@@ -11,9 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*Module       lkhead.c
index 7fb4f8ff26b7b86bb1e8e09b7a17b74d375fbca5..2e52d94b8bc4ac5369ab51eb41ef59c1611f1683 100644 (file)
@@ -11,9 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*)Module      lkihx.c
index 5e894e152af37f56d80a81405cf1d094a54570e1..d80b9ae49d82e9fa3856b1707dfb5d8b6ab5e974 100644 (file)
@@ -11,9 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*)Module      lklex.c
index 000843eed9a78796a77761ed39c9ee0c6ad6b164..84032719038eda114d6117ca2ee63d8a1e9c0fd6 100644 (file)
 
 #include <stdio.h>
 #include <string.h>
-#if defined(_MSC_VER)
-#include <malloc.h>
-#else
-#include <alloc.h>
-#endif
+//#if defined(_MSC_VER)
+//#include <malloc.h>
+//#else
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*)Module      lklibr.c
index 3842b1d9f3b4787400e5f237cd1b3131402cf7c5..11d7adc3d484fa796802d573486036ec5fa9e1ae 100644 (file)
@@ -17,9 +17,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include <stdlib.h>
 #include "aslink.h"
 
index 22fcac0b102ecf15c526b082af18327bf690d1d0..8abd00f4cd3807e9eb5546729889a7e583db20e2 100644 (file)
 
 #include <stdio.h>
 #include <string.h>
-#if defined(_MSC_VER)
-#include <stdlib.h>
-#else
-#include <alloc.h>
-#endif
+//#if defined(_MSC_VER)
+//#include <stdlib.h>
+//#else
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /* yuck - but including unistd.h causes problems on Cygwin by redefining
index dab3b0781ae57eca3063dec61700c7f49305d0e2..dd4c86f3cf2cf6895eb08ad9632ce3dcf610c47f 100644 (file)
@@ -11,9 +11,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 static void DefineGlobal( char *name, Addr_T value, int page );
index 863de3153ab99b3747693734e610c645a0ef99a7..f6ac50bfff39e80a0d1e8091a034137fc20740de 100644 (file)
@@ -16,9 +16,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*)Module      lkrloc.c
index a730df5dcc883d9a2d74e63556fbfdd4efcab11e..b222415d1cabc8133369fd2403c91d8870859d3f 100644 (file)
@@ -11,9 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*)Module      lks19.c
index 73c21d01508345f3acbe3b7fe18b73acb4bcecf8..5eb8d68f16b2ec57b181d4d37b74adc521ed427c 100644 (file)
@@ -9,9 +9,9 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 #include "aslink.h"
 
 /*
index 417d370465026f8f83afc475f06b963c5c7a8999..f4ee1b95221f36793f8dd9cd25572fab0856bec4 100644 (file)
@@ -2,9 +2,9 @@
 /* DECUS C */
 
 #ifndef SDK
-extern char    *alloc();
-extern char    *malloc();
-extern char    *calloc();
-extern char    *realloc();
+//extern       char    *alloc();
+//extern       char    *malloc();
+//extern       char    *calloc();
+//extern       char    *realloc();
 #endif
 
index 82060ae90712e53038a1885647829f91fb60269b..4af2fdcc5803d600b862e98bf6f8015eb0795176 100644 (file)
@@ -13,9 +13,9 @@
 #include <setjmp.h>
 #include <string.h>
 
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 
 #include "asm.h"
 
index d65ae50ed21b41dd394435d65118bfe918620fe6..2e2a123e82c7f1a7ca2a5d334b0d3e2b81349288 100644 (file)
@@ -13,9 +13,9 @@
 #include <setjmp.h>
 #include <string.h>
 
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 
 #include "asm.h"
 
index 4f764dd6733f667a26b3efd79d657e3d95c66603..2713ff8df26d262c9863ca13b05aade9c5cf13da 100644 (file)
@@ -17,9 +17,9 @@
 #include <setjmp.h>
 #include <string.h>
 
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 
 #include "asm.h"
 
index d65660fe238fd4dc4b06620e1c9b0c16c632de75..2c006cb3d1414cd37dc9ac36706f693c8da34573 100644 (file)
@@ -17,6 +17,7 @@
 #include <setjmp.h>
 #include <string.h>
 
+//#include "newalloc.h"
 #if defined(_MSC_VER)
 #include <malloc.h>
 #else
index 0da2d11ab657aec792d4b91365deae6c00540007..5f6d6a1ca399b4c002755d479e7d7766af95af92 100644 (file)
@@ -17,9 +17,9 @@
 #include <setjmp.h>
 #include <string.h>
 
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 
 #ifdef SDK
 #include <stdlib.h>
index 5e4c57fe105b583c9d5b8a968c730bfdf146e993..51b6bb9ad2d29d2f6256a8170ad74b0bf6605091 100644 (file)
@@ -13,9 +13,9 @@
 #include <setjmp.h>
 #include <string.h>
 
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 
 #include "asm.h"
 
index 29c37416353b1c6c1d9ab6684950a686c2420edc..2150cb45ad5f580d2cc1abdb0046ed08e88f32bb 100644 (file)
@@ -17,9 +17,9 @@
 #include <setjmp.h>
 #include <string.h>
 
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
+//#if !defined(_MSC_VER)
+//#include <alloc.h>
+//#endif
 
 #include "asm.h"
 
index 3ba14a652188e975138dd660b226482dd3dba0a6..61286f54de3270685c5bbc88c7aac42f16596fb2 100644 (file)
@@ -42,7 +42,7 @@ int setBreakPoint (unsigned addr, char addrType, char bpType,
     char simbuf[50];
 
     /* allocate & init a new bp */
-    ALLOC(bp,sizeof(breakp));
+    Safe_calloc(bp,sizeof(breakp));
     bp->addr = addr;
     bp->addrType = addrType;
     bp->bpType = bpType;
index ef85f5bb325e3cfaa2dceb502538457ba66de9b3..3cb36cc86f5033ac371eca2e705ef39a7fd7821d 100644 (file)
@@ -153,7 +153,7 @@ struct cmdtab
 char *gc_strdup(const char *s)
 {
     char *ret;
-    ALLOC_ATOMIC(ret, strlen(s)+1);
+    Safe_calloc(ret, strlen(s)+1);
     strcpy(ret, s);
     return ret;
 }
@@ -168,7 +168,7 @@ char *alloccpy ( char *s, int size)
     if (!size)
        return NULL;
 
-    ALLOC(d,size+1);
+    Safe_calloc(d,size+1);
     memcpy(d,s,size);
     d[size] = '\0';
 
@@ -183,7 +183,7 @@ void **resize (void **array, int newSize)
     void **vptr;
 
     if (array)
-       vptr = realloc(array,newSize*(sizeof(void **)));
+       vptr = Safe_realloc(array,newSize*(sizeof(void **)));
     else
        vptr = calloc(1, sizeof(void **));
     
@@ -209,7 +209,7 @@ static int readCdb (FILE *file)
     if (!(bp = fgets(buffer,sizeof(buffer),file)))
            return 0;
     
-    ALLOC(currl,sizeof(cdbrecs));
+    Safe_calloc(currl,sizeof(cdbrecs));
     recsRoot = currl ;
 
     while (1) {
@@ -237,7 +237,7 @@ static int readCdb (FILE *file)
            }
            
            bp += 2;
-           ALLOC(currl->line,strlen(bp));
+           Safe_calloc(currl->line,strlen(bp));
            strncpy(currl->line,bp,strlen(bp)-1);
            currl->line[strlen(bp)-1] = '\0';
        }
@@ -248,7 +248,7 @@ static int readCdb (FILE *file)
        if (feof(file))
            break;
        
-       ALLOC(currl->next,sizeof(cdbrecs));
+       Safe_calloc(currl->next,sizeof(cdbrecs));
        currl = currl->next;
     }
 
@@ -351,7 +351,7 @@ srcLine **loadFile (char *name, int *nlines)
 
        slines = (srcLine **)resize((void **)slines,*nlines);
 
-       ALLOC(slines[(*nlines)-1],sizeof(srcLine));
+       Safe_calloc(slines[(*nlines)-1],sizeof(srcLine));
        slines[(*nlines)-1]->src = alloccpy(bp,strlen(bp));     
     }
 
@@ -464,7 +464,7 @@ static void functionPoints ()
                if (func->exitline < j)
                    func->exitline = j;
 
-               ALLOC(ep,sizeof(exePoint));
+               Safe_calloc(ep,sizeof(exePoint));
                ep->addr =  mod->cLines[j]->addr ;
                ep->line = j;
                ep->block= mod->cLines[j]->block;
@@ -487,7 +487,7 @@ static void functionPoints ()
                    func->aexitline = j;
 
                /* add it to the execution point */
-               ALLOC(ep,sizeof(exePoint));
+               Safe_calloc(ep,sizeof(exePoint));
                ep->addr =  mod->asmLines[j]->addr ;
                ep->line = j;
                addSet(&func->afpoints,ep);     
@@ -559,7 +559,7 @@ int cmdFile (char *s,context *cctxt)
     }
 
     /* allocate for context */
-    ALLOC(currCtxt ,sizeof(context));
+    Safe_calloc(currCtxt ,sizeof(context));
     
     /* readin the debug information */
     if (!readCdb (cdbFile)) {
@@ -718,7 +718,7 @@ static void parseCmdLine (int argc, char **argv)
                if (!ssdirl)
                    ssdirl = &argv[i][12];
                else {
-                   char *p = malloc(strlen(ssdirl)+strlen(&argv[i][12])+2);
+                   char *p = Safe_malloc(strlen(ssdirl)+strlen(&argv[i][12])+2);
                    strcat(strcat(strcpy(p,&argv[i][12]),":"),ssdirl);
                    ssdirl = p;
                }
index c3bc3c206e4cb170a4cef7ea5531ecec35dc218b..02f8be0be22e88560fa36435f66e5a69ada96046 100644 (file)
@@ -48,20 +48,20 @@ typedef short bool;
 #define min(a,b) (a < b ? a : b)
 #endif
 
-#ifndef ALLOC
-#define  ALLOC(x,sz) if (!(x = calloc(1, sz)))                          \
-         {                                                           \
-            fprintf(stderr,"sdcdb: out of memory\n"); \
-            exit (1);                                                \
-         }
-#endif
-#ifndef ALLOC_ATOMIC
-#define ALLOC_ATOMIC(x,sz)   if (!(x = calloc(1, sz)))   \
-         {                                               \
-            fprintf(stderr,"sdcdb: out of memory\n"); \
-            exit (1);                                    \
-         }
-#endif
+//#ifndef ALLOC
+//#define  ALLOC(x,sz) if (!(x = calloc(1, sz)))                          \
+//         {                                                           \
+//            fprintf(stderr,"sdcdb: out of memory\n"); \
+//            exit (1);                                                \
+//         }
+//#endif
+//#ifndef ALLOC_ATOMIC
+//#define ALLOC_ATOMIC(x,sz)   if (!(x = calloc(1, sz)))   \
+//         {                                               \
+//            fprintf(stderr,"sdcdb: out of memory\n"); \
+//            exit (1);                                    \
+//         }
+//#endif
 /* generalpurpose stack related macros */
 #define  STACK_DCL(stack,type,size)                   \
          typedef  type  t_##stack   ;                 \
index 3ea0e8fd18bc5137bdc37c94009c57817704bcbd..c79906c27cdbb3071b55ef92f458b4862108a36a 100644 (file)
@@ -90,7 +90,7 @@ void parseFunc (char *line)
     function *func ;
     char *rs;
     int i;
-    ALLOC(func,sizeof(function));
+    Safe_calloc(func,sizeof(function));
     func->sym = parseSymbol(line,&rs);
     func->sym->isfunc = 1;
     func->modName = currModName ;   
@@ -119,7 +119,7 @@ static char  *parseTypeInfo (symbol *sym, char *s)
     s = ++bp;    
     while (*s != ')') { /* till we reach the end */
        link *type;
-       ALLOC(type,sizeof(link));
+       Safe_calloc(type,sizeof(link));
        if (*s == ',') s++;
 
        /* is a declarator */
@@ -240,7 +240,7 @@ symbol *parseSymbol (char *s, char **rs)
     symbol *nsym ;
     char *bp = s;
 
-    ALLOC(nsym,sizeof(symbol));
+    Safe_calloc(nsym,sizeof(symbol));
 
     /* copy over the mangled name */
     while (*bp != '(') bp++;   
@@ -335,7 +335,7 @@ module *parseModule (char *s, bool createName )
     module *nmod ;
     char buffer[512];
 
-    ALLOC(nmod,sizeof(module));    
+    Safe_calloc(nmod,sizeof(module));    
     
     addSet (&modules,nmod);
     
@@ -346,11 +346,11 @@ module *parseModule (char *s, bool createName )
     if (createName) {
        sprintf(buffer,"%s.c",s);
        
-       ALLOC(nmod->c_name,strlen(buffer)+1);
+       Safe_calloc(nmod->c_name,strlen(buffer)+1);
        strcpy(nmod->c_name,buffer);       
        
        sprintf(buffer,"%s.asm",s);
-       ALLOC(nmod->asm_name,strlen(buffer)+1);
+       Safe_calloc(nmod->asm_name,strlen(buffer)+1);
        strcpy(nmod->asm_name,buffer);              
     }
     
@@ -432,7 +432,7 @@ structdef *structWithName (char *s)
            return structs[i];
     }
 
-    ALLOC(nsdef,sizeof(structdef));
+    Safe_calloc(nsdef,sizeof(structdef));
     nsdef->tag = alloccpy(s,strlen(s));
     nsdef->sname = currModName ;
     
index 7cf18ea0dfc2f2a09a48f855623b4a1065829193..6fe4e3427fcc665b02fcd86f9f9599257ea1ba64 100644 (file)
@@ -1,37 +1,37 @@
 /*-----------------------------------------------------------------
-    printfl.c - source file for reduced version of printf 
-                
+    printfl.c - source file for reduced version of printf
+
     Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
 
     This program is free software; you can redistribute it and/or modify it
     under the terms of the GNU General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     later version.
-    
+
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-    
+
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-    
+
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
-    what you give them.   Help stamp out software-hoarding!  
+    what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
 /* following formats are supported :-
    format     output type       argument-type
      %d        decimal             int
-     %ld       decimal             long 
+     %ld       decimal             long
      %hd       decimal             short/char
      %x        hexadecimal         int
-     %lx       hexadecimal         long 
+     %lx       hexadecimal         long
      %hx       hexadecimal         short/char
      %o        octal               int
-     %lo       octal               long 
+     %lo       octal               long
      %ho       octal               short/char
      %c        character           char/short
      %s        character           _generic pointer
@@ -52,163 +52,163 @@ static data long val;
 
 static void pvalhex( long val)
 {
-       volatile char sp = SP;
-       unsigned long lval = val;
+  volatile char sp = SP;
+  unsigned long lval = val;
 
-       if (!long_flag)
-               lval &= 0x0000ffff;
+  if (!long_flag)
+    lval &= 0x0000ffff;
 
         if (short_flag)
-               lval &= 0x000000ff;
+    lval &= 0x000000ff;
 
-       while (lval) {
-               ch = "0123456789ABCDEF"[(unsigned short)lval & 0x0f];
-               _asm push _ch _endasm;
-               lval /= 16;
-       }
+  while (lval) {
+    ch = "0123456789ABCDEF"[(unsigned short)lval & 0x0f];
+    _asm push _ch _endasm;
+    lval /= 16;
+  }
 
-       while (sp != SP) {
-               _asm pop _ch _endasm;
-               putchar(ch);
+  while (sp != SP) {
+    _asm pop _ch _endasm;
+    putchar(ch);
         }
-               
+
 }
 
-static void pvaloct(long val) 
+static void pvaloct(long val)
 {
-       char sp ; 
-       unsigned long lval;    
-       sp = SP;
-       if (val < 0) {
-               lval = -val;
-               sign = 1;
-       } else {
-               lval = val;
-               sign = 0;
-       }
-               
-       if (!long_flag)
-               lval &= 0x0000ffff;
+  char sp ;
+  unsigned long lval;
+  sp = SP;
+  if (val < 0) {
+    lval = -val;
+    sign = 1;
+  } else {
+    lval = val;
+    sign = 0;
+  }
+
+  if (!long_flag)
+    lval &= 0x0000ffff;
         if (short_flag)
-               lval &= 0x000000ff;
+    lval &= 0x000000ff;
 
         while (lval) {
-               ch = (lval % 8) + '0';
-               _asm push _ch _endasm;  
+    ch = (lval % 8) + '0';
+    _asm push _ch _endasm;
                 lval = lval / 8;
-       }
-
-       if (sign) {
-               ch = '-';
-               _asm push _ch _endasm;
-       }
-               
-       
-       while (sp != SP) {
-               _asm pop _ch _endasm;
-               putchar(ch);
+  }
+
+  if (sign) {
+    ch = '-';
+    _asm push _ch _endasm;
+  }
+
+
+  while (sp != SP) {
+    _asm pop _ch _endasm;
+    putchar(ch);
         }
 }
 
-static void pvaldec(long val )  
+static void pvaldec(long val )
 {
-       char sp ; 
-       unsigned long lval;    
-       sp = SP;
-       if (val < 0) {
-               lval = -val;
-               sign = 1;
-       } else {
-               lval = val;
-               sign = 0;
-       }
-               
+  char sp ;
+  unsigned long lval;
+  sp = SP;
+  if (val < 0) {
+    lval = -val;
+    sign = 1;
+  } else {
+    lval = val;
+    sign = 0;
+  }
+
         while (lval) {
-               ch = (lval % 10) + '0';
-               _asm push _ch _endasm;  
+    ch = (lval % 10) + '0';
+    _asm push _ch _endasm;
                 lval = lval / 10;
-       }
-
-       if (sign) {
-               ch = '-';
-               _asm push _ch _endasm;
-       }
-               
-       
-       while (sp != SP) {
-               _asm pop _ch _endasm;
-               putchar(ch);
+  }
+
+  if (sign) {
+    ch = '-';
+    _asm push _ch _endasm;
+  }
+
+
+  while (sp != SP) {
+    _asm pop _ch _endasm;
+    putchar(ch);
         }
 }
 
 void printf_small (char * fmt, ... ) reentrant
 {
     va_list ap ;
+
     va_start(ap,fmt);
-     
+
     for (; *fmt ; fmt++ ) {
-       if (*fmt == '%') {
-           long_flag = string_flag = short_flag = 0;
-           fmt++ ;
-           switch (*fmt) {
-           case 'l':
-               long_flag = 1;
-               fmt++;
-               break;
-           case 'h':
-               short_flag = 1;
-               fmt++;
-           }
-           
-           switch (*fmt) {
-           case 's':
-               string_flag = 1;
-               break;
-           case 'd':
-               radix = 10;
-               break;
-           case 'x':
-               radix = 16;
-               break;
-           case 'c':
-               radix = 0;
-               break;
-           case 'o':
-               radix = 8;
-               break;
-           }
-
-           if (string_flag) {
-               str = va_arg(ap,char _generic *);
-               while (*str) putchar(*str++);          
-               continue ;
-           }
-           
-           if (long_flag)
-               val = va_arg(ap,long);
-           else
-               if (short_flag)
-                   val = va_arg(ap,short);
-               else
-                   val = va_arg(ap,int);
-           
+  if (*fmt == '%') {
+      long_flag = string_flag = short_flag = 0;
+      fmt++ ;
+      switch (*fmt) {
+      case 'l':
+    long_flag = 1;
+    fmt++;
+    break;
+      case 'h':
+    short_flag = 1;
+    fmt++;
+      }
+
+      switch (*fmt) {
+      case 's':
+    string_flag = 1;
+    break;
+      case 'd':
+    radix = 10;
+    break;
+      case 'x':
+    radix = 16;
+    break;
+      case 'c':
+    radix = 0;
+    break;
+      case 'o':
+    radix = 8;
+    break;
+      }
+
+      if (string_flag) {
+    str = va_arg(ap,char _generic *);
+    while (*str) putchar(*str++);
+    continue ;
+      }
+
+      if (long_flag)
+    val = va_arg(ap,long);
+      else
+    if (short_flag)
+        val = va_arg(ap,short);
+    else
+        val = va_arg(ap,int);
+
             switch (radix) {
-           case 10:
-               pvaldec(val) ; 
-               break;
-           case 16:
-               pvalhex (val); 
-               break;
-           case 0:
-               putchar((char)val);
-               break;
-           case 8:
-               pvaloct(val) ; 
-               break;
-           }
-           
-       } else
-           putchar(*fmt);       
-    }    
+      case 10:
+    pvaldec(val) ;
+    break;
+      case 16:
+    pvalhex (val);
+    break;
+      case 0:
+    putchar((char)val);
+    break;
+      case 8:
+    pvaloct(val) ;
+    break;
+      }
+
+  } else
+      putchar(*fmt);
+    }
 }
index e5999621c60bec1eb467cfdd7433fdd3da9b8f39..4e730bef6c41de399028edf078b79257e37b5884 100644 (file)
@@ -480,7 +480,7 @@ int buildlibraryindex()
                                relfil[NINPUT+1] = '\0';
                                relfil[strlen(relfil) - 1] = '\0';
                                if (path != NULL) {
-                                       str = (char *)malloc(strlen(path)+strlen(relfil)+6);
+                                       str = (char *)Safe_malloc(strlen(path)+strlen(relfil)+6);
                                        strcpy(str,path);
 #ifdef OTHERSYSTEM
 #ifdef SDK
@@ -498,7 +498,7 @@ int buildlibraryindex()
                                        }
 #endif
                                } else {
-                                       str = (char *)malloc(strlen(relfil) + 5);
+                                       str = (char *)Safe_malloc(strlen(relfil) + 5);
                                }
 #ifdef SDK
 #ifdef UNIX
@@ -523,7 +523,7 @@ int buildlibraryindex()
 /*3*/                          if ((fp = fopen(str, "r")) != NULL) {
 
                                        /* Opened OK - create a new libraryfile object for it */
-                                       This->next = (pmlibraryfile)malloc( sizeof( mlibraryfile ));
+                                       This->next = (pmlibraryfile)Safe_malloc( sizeof( mlibraryfile ));
                                        if (This->next == NULL) {
                                                printf("panic: cant allocate memory.\n");
                                                exit(-1);
index cf6cc71fdc326b4775eabbbdce60b085cdb9fca5..fbf47893160fb3c351dffe09a1af8152f51cfea9 100644 (file)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /WX /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /J /FD /c
+# ADD CPP /nologo /G3 /Zp1 /W3 /WX /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -67,7 +67,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index 0677a76e5c6dbb3fa96f75780260369dfb4a5224..ca2e5156037f966c323b6e4b86214cc7214706ef 100644 (file)
--- a/sdcc_vc.h
+++ b/sdcc_vc.h
@@ -32,6 +32,8 @@
 #undef OPT_DISABLE_GBZ80
 #undef OPT_DISABLE_MCS51
 #undef OPT_DISABLE_AVR
+#define OPT_DISABLE_I186      1
+#define OPT_DISABLE_TLCS900H  1
 
 #endif
 
index edd42cf00205ed85f7ea059a609a8e7a2828d508..a668b0aed4f095474c602d77bdab90de8b8f56e1 100644 (file)
@@ -34,6 +34,7 @@ IS       (u|U|l|L)*
 #include <string.h>
 #include <ctype.h>
 #include "common.h"
+#include "newalloc.h"
     
 char *stringLiteral();
 char *currFname;
@@ -262,7 +263,7 @@ int checkCurrFile ( char *s)
        /* mark the end of the filename */
        while (*s != '"') s++;
        *s = '\0';
-       ALLOC(currFname,strlen(sb)+1);
+       currFname = Safe_calloc(strlen(sb)+1);
        strcpy(currFname,sb);
        yylineno = lNum - 2;
     }
index 8dd9d97b149b968169b419fb3f7cbb033b1c6b4b..02fce6ea68df0f6878f60977a0e575bd8954f578 100644 (file)
@@ -32,6 +32,7 @@
 #include "SDCCmem.h"
 #include "SDCCast.h"
 #include "port.h"
+#include "newalloc.h"
 
 extern int yyerror (char *);
 extern FILE    *yyin;
@@ -1113,7 +1114,7 @@ statement
    | jump_statement
    | INLINEASM  ';'      {
                             ast *ex = newNode(INLINEASM,NULL,NULL);
-                           ALLOC(ex->values.inlineasm,strlen($1));
+                           ex->values.inlineasm = Safe_calloc(strlen($1));
                            strcpy(ex->values.inlineasm,$1);                        
                            $$ = ex;
                          }   
index 5d975e5f25e44e0ad85af0429905ef2cb8a86d51..2059b3d7a622a76d49d0a8b531e0b694126aca5e 100644 (file)
@@ -24,6 +24,7 @@
 -------------------------------------------------------------------------*/
 
 #include "common.h"
+#include "newalloc.h"
 
 int eBBNum = 0;
 set *graphEdges = NULL ;  /* list of edges in this flow graph */
@@ -46,7 +47,7 @@ eBBlock *neweBBlock ()
 {
     eBBlock *ebb;
 
-    ALLOC(ebb,sizeof(eBBlock));   
+    ebb = Safe_calloc(sizeof(eBBlock));   
     return ebb ;
 }
 
@@ -57,7 +58,7 @@ edge *newEdge (eBBlock *from, eBBlock *to)
 {
     edge *ep ;
 
-    ALLOC(ep,sizeof(edge));     
+    ep = Safe_calloc(sizeof(edge));     
     
     ep->from = from;
     ep->to = to;
@@ -385,7 +386,8 @@ eBBlock **iCodeBreakDown (iCode *ic, int *count)
     *count = 0 ;
 
     /* allocate for the first entry */
-    ALLOC(ebbs,sizeof(eBBlock **));
+
+    ebbs = Safe_calloc(sizeof(eBBlock **));
        
     while (loop) {       
 
@@ -400,12 +402,10 @@ eBBlock **iCodeBreakDown (iCode *ic, int *count)
        /* put it in the array */
        ebbs[(*count)++] = ebb ;
        
-         /* allocate for the next one. Remember to clear the new */
-         /*  pointer at the end, that was created by realloc. */
-       if (!(ebbs = realloc(ebbs,(*count + 1)*sizeof(eBBlock **)))) {
-           werror(E_OUT_OF_MEM,__FILE__,(*count + 1)*sizeof(eBBlock **)); 
-           exit (1);
-       }
+       /* allocate for the next one. Remember to clear the new */
+       /*  pointer at the end, that was created by realloc. */
+
+       ebbs = Safe_realloc(ebbs,(*count + 1)*sizeof(eBBlock **)) ;
 
        ebbs[*count] = 0;
 
@@ -444,11 +444,11 @@ eBBlock **iCodeBreakDown (iCode *ic, int *count)
                }
                
                (*count)++ ;
+               
                /* if we have stopped at the block , allocate for an extra one */
-               if (!(ebbs = realloc(ebbs,(*count + 1)*sizeof(eBBlock **)))) {
-                   werror(E_OUT_OF_MEM,__FILE__,(*count + 1)*sizeof(eBBlock **)); 
-                   exit (1);
-               }
+
+               ebbs = Safe_realloc(ebbs,(*count + 1)*sizeof(eBBlock **)) ;
+
                ebbs[*count] = 0;
                
                /* then move the block down one count */  
index b12a5e397c194026c0fa3de83d3e2fe7766c7092..f4bf9a65a4a6c941972b776107f6bd872b65bfa5 100644 (file)
@@ -91,4 +91,15 @@ iCode      *iCodeFromeBBlock ( eBBlock **,int);
 int         otherPathsPresent (eBBlock **,eBBlock *);
 void        replaceLabel(eBBlock *,symbol *,symbol *);
 void        dumpEbbsToFileExt (char *,eBBlock **,int);
+
+#if defined(_MSC_VER)
+
+/*-----------------------------------------------------------------*/
+/* dumpLiveRanges - dump liverange information into a file         */
+/*-----------------------------------------------------------------*/
+
+void dumpLiveRanges (char *ext,hTab *liveRanges) ;
+
+#endif   // _MSC_VER
+
 #endif
index ff75fff7a9d74e76a945fe2f39d902039cbba8af..04be19210b08ee0f4d1944f2539e7236267983fb 100644 (file)
@@ -23,6 +23,7 @@
 -------------------------------------------------------------------------*/
 
 #include "common.h"
+#include "newalloc.h"
 
 int currLineno  = 0;
 set *astList = NULL ;
@@ -71,7 +72,7 @@ ast  *newAst (int  type, void *op )
     ast  *ex ;
     static int oldLineno = 0 ;
 
-    ALLOC(ex,sizeof(ast));    
+    Safe_calloc(ex,sizeof(ast));    
     
     ex->type = type ;          
     ex->lineno = (noLineno ? oldLineno : yylineno);
@@ -104,7 +105,7 @@ static ast* newAst_(unsigned type)
     ast  *ex ;
     static int oldLineno = 0 ;
 
-    ALLOC(ex,sizeof(ast));    
+    ex = Safe_calloc(sizeof(ast));    
     
     ex->type = type ;          
     ex->lineno = (noLineno ? oldLineno : yylineno);
@@ -206,7 +207,7 @@ void copyAstValues (ast *dest,ast *src)
        break ;
        
     case INLINEASM:
-       ALLOC(dest->values.inlineasm,strlen(src->values.inlineasm));
+       dest->values.inlineasm = Safe_calloc(strlen(src->values.inlineasm));
        strcpy(dest->values.inlineasm,src->values.inlineasm);
 
     case FOR:
@@ -230,7 +231,7 @@ ast  *copyAst (ast   *src)
     
     if (!src)  return NULL ;
    
-    ALLOC(dest,sizeof(ast));
+    dest = Safe_calloc(sizeof(ast));
     
     dest->type = src->type  ;
     dest->lineno = src->lineno ;
index fe8e1b603a6b5872e2fbab72465260ddfe77baef..c5ec50daa9197442c87858dd47efe9e0c2f4ad78 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "common.h"
 
+#include "newalloc.h"
+
 int bitVectDefault = 1024;
 
 /* genernal note about a bitvectors:
@@ -38,11 +40,11 @@ bitVect *newBitVect (int size)
     bitVect *bvp;
     int byteSize ;
 
-    ALLOC(bvp,sizeof (bitVect));
+    bvp = Safe_calloc(sizeof (bitVect));
 
     bvp->size = size;    
     bvp->bSize = byteSize = ( size / 8) + 1 ;
-    ALLOC(bvp->vect,byteSize);
+    bvp->vect = Safe_calloc(byteSize);
     return bvp;
 }
 
@@ -63,9 +65,10 @@ bitVect *bitVectResize (bitVect *bvp, int size)
        return bvp;
     }
 
+    bvp->vect = Clear_realloc(bvp->vect, bvp -> bSize, bSize);
     bvp->size = size;
     bvp->bSize= bSize;
-    bvp->vect = realloc(bvp->vect, bSize);
+
     return bvp;
 }
 
index ba572b6aded494d0b7568d79d19f96a5ca54612c..f3ebccab594881246566b1c9b6d7cabff8d84567 100644 (file)
@@ -23,6 +23,7 @@
 -------------------------------------------------------------------------*/
 
 #include "common.h"
+#include "newalloc.h"
 
 /*-----------------------------------------------------------------*/
 /* newCseDef - new cseDef                                          */
@@ -32,7 +33,7 @@ cseDef *newCseDef (operand *sym, iCode *ic)
     cseDef *cdp ;
     
     assert (sym);
-    ALLOC(cdp,sizeof(cseDef));    
+    cdp = Safe_calloc(sizeof(cseDef));    
 
     cdp->sym = sym;
     cdp->diCode = ic;
index f7877795be0952385e5ca373157a094ea5412e92..0b78524fe678d68d1a99423fedb6156015be4ffd 100644 (file)
@@ -88,18 +88,18 @@ typedef int bool;
     type *type##FreeStack [size]  ; \
     int   type##StackPtr = 0      ;
 
-#define  ALLOC(x,sz) if (!(x = calloc(1, sz)))      \
-         {                                          \
-            werror(E_OUT_OF_MEM,__FILE__,(long) sz);\
-            exit (1);                               \
-         }
-
-
-#define ALLOCTYPE(type,size) if (!(type##Pool = calloc(1, size*sizeof(type))))\
-         {                                                            \
-            werror(E_OUT_OF_MEM,__FILE__,(long) size);               \
-            exit (1);                                                \
-         }
+//#define  ALLOC(x,sz) if (!(x = calloc(1, sz)))      \
+//         {                                          \
+//            werror(E_OUT_OF_MEM,__FILE__,(long) sz);\
+//            exit (1);                               \
+//         }
+
+
+//#define ALLOCTYPE(type,size) if (!(type##Pool = calloc(1, size*sizeof(type))))\
+//         {                                                            \
+//            werror(E_OUT_OF_MEM,__FILE__,(long) size);                     \
+//            exit (1);                                                \
+//         }
 
 #define PUSH(x,y)   x##FreeStack[x##StackPtr++] = y
 #define PEEK(x)     x##FreeStack[x##StackPtr-1]
index 3cd5c434c72075cc38808ca87d78ed912d60a570..901d291136e7482890f811552a7e59218321cb5e 100644 (file)
@@ -25,6 +25,7 @@
 #include "common.h"
 #include "asm.h"
 #include <time.h>
+#include "newalloc.h"
 
 #if    !defined(__BORLANDC__) && !defined(_MSC_VER)
 #if 0 /* This should no longer be necessary. */
@@ -121,7 +122,7 @@ char *aopLiteralLong(value *val, int offset, int size)
            /* Hmm.  Too big for now. */
            assert(0);
        }
-        ALLOC(rs,strlen(buffer)+1);
+        rs = Safe_calloc(strlen(buffer)+1);
         return strcpy (rs,buffer);
     }
 
@@ -135,7 +136,7 @@ char *aopLiteralLong(value *val, int offset, int size)
 #else
     tsprintf(buffer, "!immedbyte", fl.c[offset]);
 #endif
-    ALLOC(rs,strlen(buffer)+1);
+    rs = Safe_calloc(strlen(buffer)+1);
     return strcpy (rs,buffer);
 }
 
@@ -1350,6 +1351,7 @@ void glue ()
 */
 FILE *tempfile(void)
 {
+#if !defined(_MSC_VER)
     const char *tmpdir = NULL;
     if (getenv("TMP"))
        tmpdir = getenv("TMP");
@@ -1369,13 +1371,14 @@ FILE *tempfile(void)
        }
        return NULL;
     }
+#endif
     return tmpfile();
 }
 
 char *gc_strdup(const char *s)
 {
     char *ret;
-    ALLOC(ret, strlen(s)+1);
+    ret = Safe_calloc(strlen(s)+1);
     strcpy(ret, s);
     return ret;
 }
index 9703326569f3e1a24a673f58fbb6f5f2e77f91b4..22b453ce1a78cbe2ecaea84f7aff6a7f2a4c9338 100644 (file)
@@ -28,6 +28,7 @@
 #include <assert.h>
 #include "SDCCglobl.h"
 #include "SDCChasht.h"
+#include "newalloc.h"
 
 #define DEFAULT_HTAB_SIZE 128
 
@@ -38,7 +39,7 @@ static hashtItem *_newHashtItem (int key, void *pkey, void *item)
 {
     hashtItem *htip;
 
-    ALLOC(htip,sizeof(hashtItem));
+    htip = Safe_calloc(sizeof(hashtItem));
     
     htip->key = key ;
     htip->pkey = pkey;
@@ -54,7 +55,7 @@ hTab *newHashTable (int size)
 {
     hTab *htab;    
     
-    ALLOC(htab,sizeof(hTab));  
+    htab = Safe_calloc(sizeof(hTab));  
 
     if (!(htab->table = calloc((size +1),  sizeof(hashtItem *)))) {
        fprintf(stderr,"out of virtual memory %s %d\n",
@@ -76,7 +77,7 @@ void hTabAddItemLong(hTab **htab, int key, void *pkey, void *item)
     
     if (key > (*htab)->size ) {        
        int i;       
-       (*htab)->table = realloc ((*htab)->table, 
+       (*htab)->table = Safe_realloc ((*htab)->table, 
                                  (key*2 + 2)*sizeof(hashtItem *));
        for ( i = (*htab)->size +1; i <= (key*2 + 1); i++ )
            (*htab)->table[i] = NULL ;
index 9d82ef56774d4535b0054d1087ef8637509f87e8..19c833bebf3b2e2b58f417420b71fa805ee1ace8 100644 (file)
@@ -23,6 +23,7 @@
 -------------------------------------------------------------------------*/
 
 #include "common.h"
+#include "newalloc.h"
 
 /*-----------------------------------------------------------------*/
 /* global variables       */
@@ -412,7 +413,7 @@ operand *newOperand ()
 {
     operand *op ;
     
-    ALLOC(op,sizeof(operand));
+    op = Safe_calloc(sizeof(operand));
     
     op->key = 0 ;
     return op;
@@ -425,7 +426,7 @@ iCode *newiCode (int op, operand *left, operand *right)
 {
     iCode *ic ;
     
-    ALLOC(ic,sizeof(iCode));
+    ic = Safe_calloc(sizeof(iCode));
    
     ic->lineno = lineno ;
     ic->filename= filename ;
index 4cf349c4e285450d4a8e52e2ec1a345b03d81ac7..64d3d502ad221c016cd39610d9af820481e4a816 100644 (file)
@@ -24,6 +24,7 @@
 -------------------------------------------------------------------------*/
 
 #include "common.h"
+#include "newalloc.h"
 
 DEFSETFUNC(isDefAlive);
 
@@ -37,7 +38,7 @@ induction *newInduction (operand *sym, unsigned int op,
 {
     induction *ip;
 
-    ALLOC(ip,sizeof(induction));
+    ip = Safe_calloc(sizeof(induction));
 
     ip->sym = sym;
     ip->asym= asym;
@@ -55,7 +56,7 @@ region *newRegion ()
 {
     region *lp ;
 
-    ALLOC(lp,sizeof(region));  
+    lp = Safe_calloc(sizeof(region));  
 
     return lp;
 }
index 4a4c7a6b35f6fc471725e6a3d38f9271212d6027..2d44d46607a1bb8eabeb11f9a582e2666a07f77b 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "common.h"
 #include <ctype.h>
+#include "newalloc.h"
 
 #if NATIVE_WIN32
 #include <process.h>
@@ -71,6 +72,14 @@ int nrelFiles = 0;
 bool verboseExec = FALSE;
 char    *preOutName;
 
+// In MSC VC6 default search path for exe's to path for this
+
+#if defined(_MSC_VER)
+
+char DefaultExePath[_MAX_PATH] ;
+
+#endif
+
 /* Far functions, far data */
 #define OPTION_LARGE_MODEL "-model-large"
 /* Far functions, near data */
@@ -474,7 +483,7 @@ static void processFile (char *s)
        
        /* get rid of the "." */
        strtok(buffer,".");
-       ALLOC(srcFileName,strlen(buffer)+1);
+       srcFileName = Safe_calloc(strlen(buffer)+1);
        strcpy(srcFileName,buffer);
 
        /* get rid of any path information 
@@ -487,7 +496,7 @@ static void processFile (char *s)
               *(fext-1) != '/'   &&
               *(fext-1) != ':')
            fext--;
-       ALLOC(moduleName,strlen(fext)+1);
+       moduleName = Safe_calloc(strlen(fext)+1);
        strcpy(moduleName,fext);
        
        return ;
@@ -1138,7 +1147,7 @@ int   parseCmdLine ( int argc, char **argv )
 
 #if defined(_MSC_VER)
 
-char *try_dir[]= {NULL}; // TODO : Fill in some default search list
+char *try_dir[]= {DefaultExePath, NULL};                       // TODO : Fill in some default search list
 
 #else
 
@@ -1198,14 +1207,16 @@ int my_system (const char *cmd)
   }
   return e;
 }
+
 #else
+
 int my_system (const char *cmd, char **cmd_argv)
 {    
     char *dir, *got= NULL; int i= 0;
 
     while (!got && try_dir[i])
     {
-        dir= (char*)malloc(strlen(try_dir[i])+strlen(cmd)+10);
+        dir= (char*)Safe_malloc(strlen(try_dir[i])+strlen(cmd)+10);
         strcpy(dir, try_dir[i]);
         strcat(dir, "/");
         strcat(dir, cmd);
@@ -1548,6 +1559,28 @@ int main ( int argc, char **argv , char **envp)
     if (port->init)
        port->init();
 
+#if defined(_MSC_VER)
+
+      {
+      int i ;
+
+      // Create a default exe search path from the path to the sdcc command
+
+      strcpy(DefaultExePath,argv[0]) ;
+
+      for(i = strlen(DefaultExePath) ; i > 0 ; i--)
+       if (DefaultExePath[i] == '\\')
+         {
+         DefaultExePath[i] = '\0' ;
+         break ;
+         }
+
+      if (i == 0)
+       DefaultExePath[0] = '\0' ;
+      }
+
+#endif
+
     setDefaultOptions();
     parseCmdLine(argc,argv);
 
@@ -1630,4 +1663,4 @@ int main ( int argc, char **argv , char **envp)
 
     return 0;
     
-}
+  }
index 9076217726285a60b91dd2503ffcd9a6bc20b3c4..51c65eb2e2ed003952726f02c17c309bc5dbe2d1 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "common.h"
 #include "SDCCpeeph.h"
+#include "newalloc.h"
 
 peepRule *rootRules = NULL;
 peepRule *currRule  = NULL;
@@ -270,13 +271,13 @@ peepRule *newPeepRule (lineNode *match  ,
 {
     peepRule *pr ;
 
-    ALLOC(pr,sizeof(peepRule));
+    pr= Safe_calloc(sizeof(peepRule));
     pr->match = match;
     pr->replace= replace;
     pr->restart = restart;
 
     if (cond && *cond) {
-    ALLOC(pr->cond,strlen(cond)+1);
+    pr->cond = Safe_calloc(strlen(cond)+1);
     strcpy(pr->cond,cond);
     } else
     pr->cond = NULL ;
@@ -299,8 +300,8 @@ lineNode *newLineNode (char *line)
 {
     lineNode *pl;
 
-    ALLOC(pl,sizeof(lineNode));
-    ALLOC(pl->line,strlen(line)+1);
+    pl = Safe_calloc(sizeof(lineNode));
+    pl->line = Safe_calloc(strlen(line)+1);
     strcpy(pl->line,line);
     return pl;
 }
@@ -506,7 +507,7 @@ static void bindVar (int key, char **s, hTab **vtab)
     *s = vvx ;
     *vv = '\0';
     /* got value */
-    ALLOC(vvx,strlen(vval)+1);
+    vvx = Safe_calloc(strlen(vval)+1);
     strcpy(vvx,vval);
     hTabAddItem(vtab,key,vvx);
 
@@ -786,9 +787,7 @@ static void buildLabelRefCountHash(lineNode *head)
        {
            labelHashEntry *entry;
            
-           ALLOC(entry, sizeof(labelHashEntry));
-
-           assert(entry != NULL);
+           entry = Safe_calloc(sizeof(labelHashEntry));
            
            memcpy(entry->name, label, labelLen);
            entry->name[labelLen] = 0;
@@ -911,10 +910,10 @@ static char *readFileIntoBuffer (char *fname)
         lb[nch] = '\0';
         /* copy it into allocated buffer */
         if (rs) {
-        rs = realloc(rs,strlen(rs)+strlen(lb)+1);
+        rs = Safe_realloc(rs,strlen(rs)+strlen(lb)+1);
         strcat(rs,lb);
         } else {
-        ALLOC(rs,strlen(lb)+1);
+        rs = Safe_calloc(strlen(lb)+1);
         strcpy(rs,lb);
         }
         nch = 0 ;
@@ -926,10 +925,10 @@ static char *readFileIntoBuffer (char *fname)
     lb[nch] = '\0';
     /* copy it into allocated buffer */
     if (rs) {
-        rs = realloc(rs,strlen(rs)+strlen(lb)+1);
+        rs = Safe_realloc(rs,strlen(rs)+strlen(lb)+1);
         strcat(rs,lb);
     } else {
-        ALLOC(rs,strlen(lb)+1);
+        rs = Safe_calloc(strlen(lb)+1);
         strcpy(rs,lb);
     }
     }
index f1f039d0386e05026bb8d6e9531f990e6c122e9d..25fbf0c2f34a9213c39c2de2e0f65cd5518f56bb 100644 (file)
@@ -23,7 +23,7 @@
 -------------------------------------------------------------------------*/
 
 #include <stdio.h>
-#include <malloc.h>
+#include "newalloc.h"
 #include <assert.h>
 #include "SDCCset.h"
 
@@ -34,11 +34,11 @@ set *newSet  ()
 {
   set *lp ;
 
-  lp = calloc(1, sizeof(set));
-  if (lp == 0) {
-       fprintf(stderr, "out of virtual memory: %s\n", __FILE__);
-       exit(1);
-  }
+  lp = Safe_calloc(sizeof(set));
+//  if (lp == 0) {
+//     fprintf(stderr, "out of virtual memory: %s\n", __FILE__);
+//     exit(1);
+//  }
 
   lp->item = lp->curr= lp->next = NULL;
   return lp;
index 8ff43f183551df88f512313543b97d1ab7cc590a..294cb8e5138f3da5dbd043f1a1fdc4c655ce7abe 100644 (file)
@@ -22,6 +22,7 @@
 -------------------------------------------------------------------------*/
 
 #include "common.h"
+#include "newalloc.h"
 
 bucket   *SymbolTab [256]  ;  /* the symbol    table  */
 bucket   *StructTab [256]  ;  /* the structure table  */
@@ -48,7 +49,7 @@ bucket         *newBucket ()
 {
        bucket *bp ;
              
-       ALLOC(bp,sizeof(bucket));
+       bp = Safe_calloc(sizeof(bucket));
        
        return bp ;
 }
@@ -80,7 +81,7 @@ void  addSym ( bucket **stab ,
     /* the symbols are always added at the head of the list  */
     i = hashKey(sname) ;      
     /* get a free entry */
-    ALLOC(bp,sizeof(bucket));
+    bp = Safe_calloc(sizeof(bucket));
     
     bp->sym = sym ;    /* update the symbol pointer  */
     bp->level = level;   /* update the nest level      */   
@@ -221,7 +222,7 @@ symbol *newSymbol (char *name, int scope )
 {
    symbol *sym ;
    
-   ALLOC(sym,sizeof(symbol));   
+   sym = Safe_calloc(sizeof(symbol));   
 
    strcpy(sym->name,name);             /* copy the name    */
    sym->level = scope ;                /* set the level    */
@@ -237,7 +238,7 @@ sym_link  *newLink ()
 {
    sym_link *p ;
 
-   ALLOC(p,sizeof(sym_link));
+   p = Safe_calloc(sizeof(sym_link));
 
    return p;
 }
@@ -249,7 +250,7 @@ structdef   *newStruct  ( char   *tag   )
 {
    structdef  *s;
 
-   ALLOC(s,sizeof(structdef));
+   s = Safe_calloc(sizeof(structdef));
    
    strcpy(s->tag,tag) ;                     /* copy the tag            */
    return s ;
index 644054df96d5300049e5a7540a1d0d12de991ce0..83885665f266151e9e66c5b5e037f0ff599ea79e 100644 (file)
@@ -27,6 +27,7 @@
 #include <math.h>
 #include <stdlib.h>
 #include <limits.h>
+#include "newalloc.h"
 
 int            cNestLevel ;
 
@@ -37,7 +38,7 @@ value *newValue ()
 {
     value *val ;
     
-    ALLOC(val,sizeof(value));
+    val = Safe_calloc(sizeof(value));
     
     return val ;
 }
@@ -50,7 +51,7 @@ initList *newiList ( int type, void *ilist)
     initList *nilist;
     
     
-    ALLOC(nilist,sizeof(initList));    
+    nilist = Safe_calloc(sizeof(initList));    
     
     nilist->type = type        ;
     nilist->lineno = yylineno ;
@@ -402,7 +403,7 @@ value *strVal  ( char       *s )
     SPEC_NOUN(val->etype)   =  V_CHAR   ;
     SPEC_SCLS(val->etype)   =  S_LITERAL;
     
-    ALLOC(SPEC_CVAL(val->etype).v_char,strlen(s)+1);
+    SPEC_CVAL(val->etype).v_char = Safe_calloc(strlen(s)+1);
     copyStr (SPEC_CVAL(val->etype).v_char,s);
     return val;
 }
index d47e808f668cd0ab1a926b483456b73f6d9b2c59..ccda6ac82713d1730b2683fdbb46cd21eb76a3a6 100644 (file)
@@ -41,7 +41,7 @@ RSC=rc.exe
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /J /FD /Zm500 /c
+# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /Zm500 /c
 # SUBTRACT CPP /WX
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
@@ -65,8 +65,7 @@ LIB32=link.exe -lib
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c
-# SUBTRACT CPP /WX
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index 40fdc977f610a04d754e1a75b5ea77840ef43373..1a8ffb63bb134dfce79c2ee52d5503ac65796299 100644 (file)
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "SDCCglobl.h"
+#include "newalloc.h"
 
 #ifdef HAVE_SYS_ISA_DEFS_H
 #include <sys/isa_defs.h>
@@ -234,7 +235,7 @@ static asmop *newAsmop (short type)
 {
        asmop *aop;
 
-       ALLOC(aop,sizeof(asmop));
+       aop = Safe_calloc(sizeof(asmop));
        aop->type = type;
        return aop;
 }
@@ -322,7 +323,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result)
        /* special case for a function */
        if (IS_FUNC(sym->type)) {   
                sym->aop = aop = newAsmop(AOP_IMMD);    
-               ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1);
+               aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1);
                strcpy(aop->aopu.aop_immd,sym->rname);
                aop->size = FPTRSIZE; 
                return aop;
@@ -372,7 +373,7 @@ static asmop *aopForRemat (symbol *sym)
        else
                strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname);
 
-       ALLOC(aop->aopu.aop_immd,strlen(buffer)+1);
+       aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1);
        strcpy(aop->aopu.aop_immd,buffer);    
        return aop;        
 }
index caff518c2b840cae467f0a611083f2eb3ba93a2c..8ac20eb685af805b57caaefa73569a2f2a227d34 100644 (file)
@@ -41,7 +41,7 @@ RSC=rc.exe
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /Fp"Release/ds390.pch" /YX /J /FD /Zm500 /c
+# ADD CPP /nologo /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /Fp"Release/ds390.pch" /YX /FD /Zm500 /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -64,8 +64,7 @@ LIB32=link.exe -lib
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c
-# SUBTRACT CPP /WX
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index f202e191f253d8b9c695a24ca3dd070d32701fa2..9ff7e1148f6419d5cd3df1e0c38cdc552dc22034 100644 (file)
@@ -37,6 +37,7 @@
 #include "ralloc.h"
 #include "gen.h"
 #include "SDCCglobl.h"
+#include "newalloc.h"
 
 #ifdef HAVE_SYS_ISA_DEFS_H
 #include <sys/isa_defs.h>
@@ -254,7 +255,7 @@ static asmop *newAsmop (short type)
 {
     asmop *aop;
 
-    ALLOC(aop,sizeof(asmop));
+    aop = Safe_calloc(sizeof(asmop));
     aop->type = type;
     return aop;
 }
@@ -479,7 +480,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result, bool useDP2)
     /* special case for a function */
     if (IS_FUNC(sym->type)) {   
         sym->aop = aop = newAsmop(AOP_IMMD);    
-        ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1);
+        aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1);
         strcpy(aop->aopu.aop_immd,sym->rname);
         aop->size = FPTRSIZE; 
         return aop;
@@ -537,7 +538,7 @@ static asmop *aopForRemat (symbol *sym)
     else
        strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname);
 
-    ALLOC(aop->aopu.aop_immd,strlen(buffer)+1);
+    aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1);
     strcpy(aop->aopu.aop_immd,buffer);    
     return aop;        
 }
@@ -908,7 +909,7 @@ static char *aopGet (asmop *aop,
            return (dname ? "acc" : "a");
        }       
        sprintf(s,"@%s",aop->aopu.aop_ptr->name);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
@@ -974,7 +975,7 @@ static char *aopGet (asmop *aop,
            else
                sprintf(s,"#%s",
                        aop->aopu.aop_immd);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
@@ -985,7 +986,7 @@ static char *aopGet (asmop *aop,
                    offset);
        else
            sprintf(s,"%s",aop->aopu.aop_dir);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
index fe68ff176d236c0d5c930a2744d1dbb461856730..22f17582ade1aa0a3994ccbe72555a1c0d8ad3c0 100644 (file)
@@ -33,6 +33,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "SDCCglobl.h"
+#include "newalloc.h"
 
 #ifdef HAVE_SYS_ISA_DEFS_H
 #include <sys/isa_defs.h>
@@ -229,7 +230,7 @@ static asmop *newAsmop (short type)
 {
     asmop *aop;
 
-    ALLOC(aop,sizeof(asmop));
+    aop = Safe_calloc(sizeof(asmop));
     aop->type = type;
     return aop;
 }
@@ -353,7 +354,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result)
     /* special case for a function */
     if (IS_FUNC(sym->type)) {   
         sym->aop = aop = newAsmop(AOP_IMMD);    
-        ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1);
+        aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1);
         strcpy(aop->aopu.aop_immd,sym->rname);
         aop->size = FPTRSIZE; 
         return aop;
@@ -400,7 +401,7 @@ static asmop *aopForRemat (symbol *sym)
     else
        strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname);
 
-    ALLOC(aop->aopu.aop_immd,strlen(buffer)+1);
+    aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1);
     strcpy(aop->aopu.aop_immd,buffer);    
     return aop;        
 }
@@ -747,7 +748,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
            return (dname ? "acc" : "a");
        }       
        sprintf(s,"@%s",aop->aopu.aop_ptr->name);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
@@ -797,7 +798,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
            else
                sprintf(s,"#%s",
                        aop->aopu.aop_immd);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
@@ -808,7 +809,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
                    offset);
        else
            sprintf(s,"%s",aop->aopu.aop_dir);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
index 05659098b6ad42eee68fd47b265c76794c44c272..0f5899b4378a4ef0009a0078abc425457dbcb7fa 100644 (file)
@@ -41,7 +41,7 @@ RSC=rc.exe
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /J /FD /Zm500 /c
+# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /Zm500 /c
 # SUBTRACT CPP /WX
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
@@ -65,8 +65,7 @@ LIB32=link.exe -lib
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /Zm500 /GZ /c
-# SUBTRACT CPP /WX
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /Zm500 /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index 58ae61cc117274c2a1bf43fbce660f7f7d9b2b4c..f9976eeb834ead7ceb42a664d789f9bbe1675705 100644 (file)
@@ -129,7 +129,14 @@ regs *mcs51_regWithIdx (int idx)
 /*-----------------------------------------------------------------*/
 static void freeReg (regs *reg)
 {
-    reg->isFree = 1;
+  if (!reg)
+  {
+    werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
+          "freeReg - Freeing NULL register");
+    exit(1);
+  }
+
+  reg->isFree = 1;
 }
 
 
index d9757f2c492fb5ba47f51f8624abed4d5acfdde7..28acf401f542de3fd3e184dcf27f957a3b75279d 100644 (file)
@@ -34,6 +34,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "SDCCglobl.h"
+#include "newalloc.h"
 
 #if defined(_MSC_VER)
 #define __FUNCTION__           __FILE__
@@ -309,7 +310,7 @@ static asmop *newAsmop (short type)
 {
     asmop *aop;
 
-    ALLOC(aop,sizeof(asmop));
+    aop = Safe_calloc(sizeof(asmop));
     aop->type = type;
     return aop;
 }
@@ -439,7 +440,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result)
     /* special case for a function */
     if (IS_FUNC(sym->type)) {   
         sym->aop = aop = newAsmop(AOP_IMMD);    
-        ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1);
+        aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1);
         strcpy(aop->aopu.aop_immd,sym->rname);
         aop->size = FPTRSIZE; 
         return aop;
@@ -489,7 +490,7 @@ static asmop *aopForRemat (symbol *sym)
        strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname);
 
     //DEBUGemitcode(";","%s",buffer);
-    ALLOC(aop->aopu.aop_immd,strlen(buffer)+1);
+    aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1);
     strcpy(aop->aopu.aop_immd,buffer);    
     return aop;        
 }
@@ -848,7 +849,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
            return (dname ? "acc" : "a");
        }       
        sprintf(s,"@%s",aop->aopu.aop_ptr->name);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
@@ -899,7 +900,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
            else
                sprintf(s,"%s",
                        aop->aopu.aop_immd);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
@@ -910,7 +911,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
                    offset);
        else
            sprintf(s,"%s",aop->aopu.aop_dir);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
index 4613e1e06d2ecd9c12308abeded5f105dd6cf542..e34d8081935198a407a246e9e7352fc387d08220 100644 (file)
@@ -25,6 +25,7 @@
 #include "../common.h"
 #include <time.h>
 #include "ralloc.h"
+#include "newalloc.h"
 
 extern symbol *interrupts[256];
 void printIval (symbol *, sym_link *, initList *, FILE *);
@@ -88,7 +89,7 @@ char *pic14aopLiteral (value *val, int offset)
 
         v >>= (offset * 8);
         sprintf(buffer,"0x%02x",((char) v) & 0xff);
-        ALLOC(rs,strlen(buffer)+1);
+        rs = Safe_calloc(strlen(buffer)+1);
         return strcpy (rs,buffer);
     }
 
@@ -99,7 +100,7 @@ char *pic14aopLiteral (value *val, int offset)
 #else
     sprintf(buffer,"0x%02x",fl.c[offset]);
 #endif
-    ALLOC(rs,strlen(buffer)+1);
+    rs = Safe_calloc(strlen(buffer)+1);
     return strcpy (rs,buffer);
 }
 
index 08f7d7f94cd7b9bba30425cec88e699268a65ebf..80bf2d34aefee5f2794c6de3e02ff54c9ab278ab 100644 (file)
@@ -41,7 +41,7 @@ RSC=rc.exe
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /J /FD /Zm500 /c
+# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /Zm500 /c
 # SUBTRACT CPP /WX
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
@@ -65,8 +65,7 @@ LIB32=link.exe -lib
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /Zm500 /GZ /c
-# SUBTRACT CPP /WX
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /Zm500 /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index 81900514423a57cca160bb68eaf79c845f9da9ce..cb918766d2cf28cc31d1e3a37b1975e15d1d5fe9 100644 (file)
 #include "ralloc.h"
 #include "gen.h"
 
+#if defined(_MSC_VER)
+#define __FUNCTION__ __FILE__
+#endif
+
 /*-----------------------------------------------------------------*/
 /* At this point we start getting processor specific although      */
 /* some routines are non-processor specific & can be reused when   */
index 372580ee588cf483e30122a52265ca92742f6cbd..513451c4ee8e81b749eb5ff33eddcba919e3cde1 100644 (file)
@@ -68,8 +68,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c
-# SUBTRACT CPP /WX /YX
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "..\support\util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
@@ -95,6 +94,10 @@ SOURCE=.\asm.c
 # End Source File
 # Begin Source File
 
+SOURCE=..\support\Util\NewAlloc.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\SDCC.lex
 
 !IF  "$(CFG)" == "src - Win32 Release"
@@ -175,7 +178,7 @@ SOURCE=.\SDCCdflow.c
 # End Source File
 # Begin Source File
 
-SOURCE=.\SDCCerr.c
+SOURCE=..\support\Util\sdccerr.c
 # End Source File
 # Begin Source File
 
@@ -247,11 +250,15 @@ SOURCE=.\sdccy.c
 # PROP Default_Filter "h;hpp;hxx;hm;inl"
 # Begin Source File
 
+SOURCE=..\support\Util\newalloc.h
+# End Source File
+# Begin Source File
+
 SOURCE=..\sdcc_vc.h
 # End Source File
 # Begin Source File
 
-SOURCE=.\SDCCalloc.h
+SOURCE=.\SDCCBBlock.h
 # End Source File
 # Begin Source File
 
index 1d95fc8abab0d99b33bb6b0558ef69f659af00da..7a2984eb996c5ccb7df662f48cb7f52e142691d8 100644 (file)
@@ -59,6 +59,7 @@
 #include "SDCCpeeph.h"
 #include "gen.h"
 #include "SDCCglue.h"
+#include "newalloc.h"
 
 /* this is the down and dirty file with all kinds of kludgy & hacky
    stuff. This is what it is all about CODE GENERATION for a specific MCU.
@@ -334,7 +335,7 @@ static asmop *newAsmop (short type)
 {
     asmop *aop;
 
-    ALLOC(aop,sizeof(asmop));
+    aop = Safe_calloc(sizeof(asmop));
     aop->type = type;
     return aop;
 }
@@ -369,7 +370,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result, bool requires_a)
     /* special case for a function */
     if (IS_FUNC(sym->type)) {   
         sym->aop = aop = newAsmop(AOP_IMMD);    
-        ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1);
+        aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1);
         strcpy(aop->aopu.aop_immd,sym->rname);
         aop->size = 2;
         return aop;
@@ -429,7 +430,7 @@ static asmop *aopForRemat (symbol *sym)
         break;
     }
 
-    ALLOC(aop->aopu.aop_immd,strlen(buffer)+1);
+    aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1);
     strcpy(aop->aopu.aop_immd,buffer);    
     return aop;        
 }
@@ -716,7 +717,7 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash)
            tsprintf(s, "!hashedstr + %d", aop->aopu.aop_immd, offset);
        else
            tsprintf(s, "%s + %d", aop->aopu.aop_immd, offset);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
     case AOP_LIT: {
@@ -733,7 +734,7 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash)
                tsprintf(buffer, "!immedword", v);
            else
                tsprintf(buffer, "!constword", v);
-           ALLOC(rs,strlen(buffer)+1);
+           rs = Safe_calloc(strlen(buffer)+1);
            return strcpy (rs,buffer);
        }
        else {
@@ -744,7 +745,7 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash)
                tsprintf(buffer, "!immedword", f.w[offset/2]);
            else
                tsprintf(buffer, "!constword", f.w[offset/2]);
-           ALLOC(rs,strlen(buffer)+1);
+           rs = Safe_calloc(strlen(buffer)+1);
            return strcpy (rs,buffer);
        }
     }
@@ -994,7 +995,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16)
            default:
                wassert(0);
            }
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
@@ -1002,7 +1003,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16)
        wassert(IS_GB);
        emitcode("ld", "a,(%s+%d) ; x", aop->aopu.aop_dir, offset);
        sprintf(s, "a");
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
@@ -1010,7 +1011,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16)
        wassert(IS_GB);
        emitcode("ldh", "a,(%s+%d) ; x", aop->aopu.aop_dir, offset);
        sprintf(s, "a");
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
 
@@ -1027,7 +1028,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16)
        wassert(IS_Z80);
        setupPair(PAIR_IY, aop, offset);
        tsprintf(s,"!*iyx", offset);
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
 
@@ -1041,7 +1042,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16)
                offset += _G.stack.param_offset;
            tsprintf(s,"!*ixx ; x", aop->aopu.aop_stk+offset);
        }
-       ALLOC(rs,strlen(s)+1);
+       rs = Safe_calloc(strlen(s)+1);
        strcpy(rs,s);   
        return rs;
        
index 2288d0ac241c902598c838c4190f2a08a846db89..6980f7e689912db62c9aade2d46ead9ff72ad8cc 100644 (file)
@@ -41,7 +41,7 @@ RSC=rc.exe
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /J /FD /Zm500 /c
+# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /Zm500 /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -64,7 +64,7 @@ LIB32=link.exe -lib
 # PROP Intermediate_Dir ""
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
@@ -98,7 +98,7 @@ SOURCE=".\peeph-z80.def"
 !IF  "$(CFG)" == "z80 - Win32 Release"
 
 # Begin Custom Build
-InputPath=.\peeph-z80.def
+InputPath=".\peeph-z80.def"
 
 "peeph-z80.rul" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
        echo on 
@@ -109,7 +109,7 @@ InputPath=.\peeph-z80.def
 !ELSEIF  "$(CFG)" == "z80 - Win32 Debug"
 
 # Begin Custom Build
-InputPath=.\peeph-z80.def
+InputPath=".\peeph-z80.def"
 
 "peeph-z80.rul peeph.rul peeph-gbz80.rul" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
        echo on 
diff --git a/support/Util/NewAlloc.c b/support/Util/NewAlloc.c
new file mode 100644 (file)
index 0000000..920286e
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+===============================================================================
+NEWALLOC - SDCC Memory allocation functions
+
+These functions are wrappers for the standard malloc, realloc and free
+functions.
+
+
+     This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+   
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!  
+
+===============================================================================
+*/
+
+//#include "SDCCerr.h"
+
+#include <stdio.h>
+#include <malloc.h>
+#include <stdlib.h>
+#include <memory.h>
+
+#include "newalloc.h"
+/*
+-------------------------------------------------------------------------------
+Clear_realloc - Reallocate a memory block and clear any memory added with 
+out of memory error detection
+
+-------------------------------------------------------------------------------
+*/
+
+void *Clear_realloc(void *OldPtr,size_t OldSize,size_t NewSize)
+
+{
+void *NewPtr ;
+
+NewPtr = realloc(OldPtr,NewSize) ;
+
+if (!NewPtr)
+  {
+  printf("ERROR - No more memory\n") ;
+//  werror(E_OUT_OF_MEM,__FILE__,NewSize);
+  exit (1);                               
+  }
+
+if (NewPtr)
+  if (NewSize > OldSize)
+    memset((char *) NewPtr + OldSize,0x00,NewSize - OldSize) ;
+
+return NewPtr ;
+}
+/*
+-------------------------------------------------------------------------------
+Safe_realloc - Reallocate a memory block with out of memory error detection
+
+-------------------------------------------------------------------------------
+*/
+
+void *Safe_realloc(void *OldPtr,size_t NewSize)
+
+{
+void *NewPtr ;
+
+NewPtr = realloc(OldPtr,NewSize) ;
+
+if (!NewPtr)
+  {
+  printf("ERROR - No more memory\n") ;
+//  werror(E_OUT_OF_MEM,__FILE__,NewSize);
+  exit (1);                               
+  }
+
+return NewPtr ;
+}
+/*
+-------------------------------------------------------------------------------
+Safe_calloc - Allocate a block of memory from the application heap, clearing
+all data to zero and checking for out of memory errors.
+
+-------------------------------------------------------------------------------
+*/
+
+void *Safe_calloc(size_t Size)
+
+{
+void *NewPtr ;
+
+NewPtr = calloc(Size,1) ;
+
+if (!NewPtr)
+  {
+  printf("ERROR - No more memory\n") ;
+//  werror(E_OUT_OF_MEM,__FILE__,Size);
+  exit (1);                               
+  }
+
+return NewPtr ;
+}
+/*
+-------------------------------------------------------------------------------
+Safe_malloc - Allocate a block of memory from the application heap
+and checking for out of memory errors.
+
+-------------------------------------------------------------------------------
+*/
+
+void *Safe_malloc(size_t Size)
+
+{
+void *NewPtr ;
+
+NewPtr = malloc(Size) ;
+
+if (!NewPtr)
+  {
+  printf("ERROR - No more memory\n") ;
+//  werror(E_OUT_OF_MEM,__FILE__,Size);
+  exit (1);                               
+  }
+
+return NewPtr ;
+}
diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h
new file mode 100644 (file)
index 0000000..bc18d4c
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+===============================================================================
+SDCCERR - SDCC Standard error handler
+
+
+===============================================================================
+*/
+
+#if !defined(__SDCCERR_H)
+
+#define __SDCCERR_H
+
+#include <stdio.h>
+#include <stdarg.h>
+
+/* ERROR MEssage Definition */
+
+#define  E_DUPLICATE       0         /* Duplicate variable   */
+#define  E_SYNTAX_ERROR    1         /* Syntax Error         */
+#define  E_CONST_EXPECTED  2         /* constant expected    */
+#define  E_OUT_OF_MEM      3         /* malloc failed        */
+#define  E_FILE_OPEN_ERR   4         /* File open failed     */
+#define  E_INVALID_OCLASS  5         /* output class invalid */
+#define  E_CANNOT_ALLOC    6         /* cannot allocate space*/
+#define  E_OLD_STYLE       7         /* old style C ! allowed*/
+#define  E_STACK_OUT       8         /* v r out of stack     */
+#define  E_INTERNAL_ERROR   9         /* unable to alloc tvar */
+#define  E_LVALUE_REQUIRED 10        /* lvalue required      */
+#define  E_TMPFILE_FAILED  11        /* tmpfile creation failed */
+#define  E_FUNCTION_EXPECTED  12     /* function expected    */
+#define  E_USING_ERROR     13        /* using in error       */
+#define  E_SFR_INIT        14        /* init error for sbit  */
+#define  E_INIT_IGNORED    15        /* initialiser ignored  */
+#define  E_AUTO_ASSUMED    16        /* sclass auto assumed  */
+#define  E_AUTO_ABSA       17        /* abs addr for auto var*/
+#define  E_INIT_WRONG      18        /* initializer type !=  */
+#define  E_FUNC_REDEF      19        /* func name redefined  */
+#define  E_ID_UNDEF        20        /* identifer undefined  */
+#define  W_STACK_OVERFLOW  21        /* stack overflow       */
+#define  E_NEED_ARRAY_PTR  22        /* array or pointer reqd*/
+#define  E_IDX_NOT_INT     23        /* index not an integer */
+#define  E_ARRAY_BOUND     24        /* array limit exceeded */
+#define  E_STRUCT_UNION    25        /* struct,union expected*/
+#define  E_NOT_MEMBER      26        /* !struct/union member */
+#define  E_PTR_REQD        27        /* pointer required     */
+#define  E_UNARY_OP        28        /* unary operator bad op*/
+#define  E_CONV_ERR        29        /* conversion error     */
+#define  E_INT_REQD        30        /* bit field must be int*/
+#define  E_BITFLD_SIZE     31        /* bit field size > 16  */
+#define  E_TRUNCATION      32        /* high order trucation */
+#define  E_CODE_WRITE      33        /* trying 2 write to code */
+#define  E_LVALUE_CONST    34        /* lvalue is a const   */   
+#define  E_ILLEGAL_ADDR    35        /* address of bit      */
+#define  E_CAST_ILLEGAL    36        /* cast illegal        */
+#define  E_MULT_INTEGRAL   37        /* mult opernd must b integral */
+#define  E_ARG_ERROR       38        /* argument count error*/
+#define  E_ARG_COUNT       39        /* func expecting more */
+#define  E_FUNC_EXPECTED   40        /* func name expected  */
+#define  E_PLUS_INVALID    41        /* plus invalid        */
+#define  E_PTR_PLUS_PTR    42        /* pointer + pointer   */
+#define  E_SHIFT_OP_INVALID 43       /* shft op op invalid  */
+#define  E_COMPARE_OP      44        /* compare operand     */
+#define  E_BITWISE_OP      45        /* bit op invalid op   */
+#define  E_ANDOR_OP        46        /* && || op invalid    */
+#define  E_TYPE_MISMATCH   47        /* type mismatch       */
+#define  E_AGGR_ASSIGN     48        /* aggr assign         */
+#define  E_ARRAY_DIRECT    49        /* array indexing in   */
+#define  E_BIT_ARRAY       50        /* bit array not allowed  */
+#define  E_DUPLICATE_TYPEDEF  51     /* typedef name duplicate */
+#define  E_ARG_TYPE        52        /* arg type mismatch   */
+#define  E_RET_VALUE       53        /* return value mismatch  */
+#define  E_FUNC_AGGR       54        /* function returing aggr */
+#define  E_FUNC_DEF        55        /* ANSI Style def neede   */
+#define  E_DUPLICATE_LABEL 56        /* duplicate label name   */
+#define  E_LABEL_UNDEF     57        /* undefined label used   */
+#define  E_FUNC_VOID       58        /* void func ret value    */
+#define  E_VOID_FUNC       59        /* func must return value */
+#define  E_RETURN_MISMATCH 60        /* return value mismatch  */
+#define  E_CASE_CONTEXT    61        /* case stmnt without switch */
+#define  E_CASE_CONSTANT   62        /* case expression ! const*/
+#define  E_BREAK_CONTEXT   63        /* break statement invalid*/
+#define  E_SWITCH_AGGR     64        /* non integral for switch*/
+#define  E_FUNC_BODY       65        /* func has body already  */
+#define  E_UNKNOWN_SIZE    66        /* variable has unknown size */
+#define  E_AUTO_AGGR_INIT  67        /* auto aggregates no init   */
+#define  E_INIT_COUNT      68        /* too many initializers  */
+#define  E_INIT_STRUCT     69        /* struct init wrong      */
+#define  E_INIT_NON_ADDR   70        /* non address xpr for init  */
+#define  E_INT_DEFINED     71        /* interrupt already over */
+#define  E_INT_ARGS        72        /* interrupt rtn cannot have args  */
+#define  E_INCLUDE_MISSING 73       /* compiler include missing        */
+#define  E_NO_MAIN        74        /* main function undefined */
+#define         E_EXTERN_INIT     75        /* extern variable initialised     */
+#define  E_PRE_PROC_FAILED 76       /* preprocessor failed             */
+#define  E_DUP_FAILED     77        /* file DUP failed             */
+#define  E_INCOMPAT_CAST   78       /* incompatible pointer casting */
+#define  E_LOOP_ELIMINATE  79       /* loop eliminated                       */          
+#define  W_NO_SIDE_EFFECTS  80      /* expression has no side effects */
+#define  E_CONST_TOO_LARGE  81      /* constant out of range             */
+#define         W_BAD_COMPARE      82       /* bad comparison                            */
+#define  E_TERMINATING      83       /* compiler terminating                     */
+#define  W_LOCAL_NOINIT            84       /* local reference before assignment */
+#define  W_NO_REFERENCE            85          /* no reference to local variable       */
+#define         E_OP_UNKNOWN_SIZE  86          /* unknown size for operand                     */
+#define  W_LONG_UNSUPPORTED 87         /* 'long' not supported yet                     */
+#define  W_LITERAL_GENERIC  88         /* literal being cast to generic pointer */
+#define  E_SFR_ADDR_RANGE   89         /* sfr address out of range                     */
+#define         E_BITVAR_STORAGE   90          /* storage given for 'bit' variable     */
+#define  W_EXTERN_MISMATCH  91         /* extern declaration mismatches    */
+#define  E_NONRENT_ARGS            92          /* fptr non reentrant has args          */
+#define  W_DOUBLE_UNSUPPORTED 93       /* 'double' not supported yet                   */
+#define  W_IF_NEVER_TRUE    94         /* if always false                                      */
+#define  W_FUNC_NO_RETURN   95         /* no return statement found            */
+#define  W_PRE_PROC_WARNING 96         /* preprocessor generated warning   */
+#define  W_STRUCT_AS_ARG    97         /* structure passed as argument         */
+#define  E_PREV_DEF_CONFLICT 98         /* previous definition conflicts with current */
+#define  E_CODE_NO_INIT     99          /* vars in code space must have initializer */
+#define  E_OPS_INTEGRAL    100          /* operans must be integral for certian assignments */
+#define  E_TOO_MANY_PARMS  101          /* too many parameters */
+#define  E_TO_FEW_PARMS    102          /* to few parameters   */
+#define  E_FUNC_NO_CODE    103          /* fatalError          */
+#define  E_TYPE_MISMATCH_PARM 104       /* type mismatch for parameter */
+#define  E_INVALID_FLOAT_CONST 105      /* invalid floating point literal string */
+#define  E_INVALID_OP      106          /* invalid operand for some operation */
+#define  E_SWITCH_NON_INTEGER 107       /* switch value not integer */
+#define  E_CASE_NON_INTEGER 108         /* case value not integer */
+#define  E_FUNC_TOO_LARGE   109         /* function too large     */
+#define  W_CONTROL_FLOW     110         /* control flow changed due to optimization */
+#define  W_PTR_TYPE_INVALID 111         /* invalid type specifier for pointer       */
+#define  W_IMPLICIT_FUNC    112         /* function declared implicitly             */
+#define  E_CONTINUE         113         /* more than one line                       */
+#define  W_TOOMANY_SPILS    114         /* too many spils occured                   */
+#define  W_UNKNOWN_PRAGMA   115         /* #pragma directive unsupported            */
+#define  W_SHIFT_CHANGED    116         /* shift changed to zero                    */
+#define  W_UNKNOWN_OPTION   117         /* don't know the option                    */
+#define  W_UNSUPP_OPTION    118         /* processor reset has been redifned        */
+#define  W_UNKNOWN_FEXT     119         /* unknown file extension                   */
+#define  W_TOO_MANY_SRC     120         /* can only compile one .c file at a time   */
+#define  I_CYCLOMATIC       121         /* information message                      */
+#define  E_DIVIDE_BY_ZERO   122         /* / 0 */
+#define  E_FUNC_BIT         123         /* function cannot return bit */
+#define  E_CAST_ZERO        124         /* casting to from size zero  */
+#define  W_CONST_RANGE      125         /* constant too large         */
+#define  W_CODE_UNREACH     126         /* unreachable code           */
+#define  W_NONPTR2_GENPTR   127         /* non pointer cast to generic pointer */
+#define  W_POSSBUG          128         /* possible code generation error */
+#define  W_PTR_ASSIGN       129         /* incampatible pointer assignment */
+#define  W_UNKNOWN_MODEL    130                /* Unknown memory model */
+#define  E_UNKNOWN_TARGET   131         /* target not defined   */
+#define         W_INDIR_BANKED     132         /* Indirect call to a banked fun */
+#define         W_UNSUPPORTED_MODEL 133        /* Unsupported model, ignored */
+#define         W_BANKED_WITH_NONBANKED 134    /* banked and nonbanked attributes mixed */
+#define         W_BANKED_WITH_STATIC 135       /* banked and static mixed */
+#define  W_INT_TO_GEN_PTR_CAST 136     /* Converting integer type to generic pointer. */
+
+/*
+-------------------------------------------------------------------------------
+SetErrorOut - Set the error output file
+
+-------------------------------------------------------------------------------
+*/
+
+FILE * SetErrorOut(FILE *NewErrorOut) ;
+
+/*
+-------------------------------------------------------------------------------
+vwerror - Output a standard eror message with variable number of arguements
+
+-------------------------------------------------------------------------------
+*/
+
+void   vwerror (int errNum, va_list marker) ;
+
+/*
+-------------------------------------------------------------------------------
+werror - Output a standard eror message with variable number of arguements
+
+-------------------------------------------------------------------------------
+*/
+
+void   werror (int errNum, ... ) ;
+
+#endif
diff --git a/support/Util/newalloc.h b/support/Util/newalloc.h
new file mode 100644 (file)
index 0000000..e27957f
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+===============================================================================
+NEWALLOC - SDCC Memory allocation functions
+
+These functions are wrappers for the standard malloc, realloc and free
+functions.
+
+
+     This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+   
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!  
+
+===============================================================================
+*/
+
+#if !defined(_NewAlloc_H)
+
+#define _NewAlloc_H
+
+#include <memory.h>
+
+/*
+-------------------------------------------------------------------------------
+Clear_realloc - Reallocate a memory block and clear any memory added with 
+out of memory error detection
+
+-------------------------------------------------------------------------------
+*/
+
+void *Clear_realloc(void *OldPtr,size_t OldSize,size_t NewSize) ;
+
+/*
+-------------------------------------------------------------------------------
+Safe_realloc - Reallocate a memory block with out of memory error detection
+
+-------------------------------------------------------------------------------
+*/
+
+void *Safe_realloc(void *OldPtr,size_t NewSize) ;
+
+/*
+-------------------------------------------------------------------------------
+Safe_calloc - Allocate a block of memory from the application heap, clearing
+all data to zero and checking for out or memory errors.
+
+-------------------------------------------------------------------------------
+*/
+
+void *Safe_calloc(size_t Size) ;
+
+/*
+-------------------------------------------------------------------------------
+Safe_malloc - Allocate a block of memory from the application heap
+and checking for out or memory errors.
+
+-------------------------------------------------------------------------------
+*/
+
+void *Safe_malloc(size_t Size) ;
+
+#endif
diff --git a/support/Util/sdccerr.c b/support/Util/sdccerr.c
new file mode 100644 (file)
index 0000000..4507bb6
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+===============================================================================
+ERROR - Standard error handler
+
+
+===============================================================================
+*/
+
+#include <stdio.h>
+
+#include "sdccerr.h"
+
+#define USE_STDOUT_FOR_ERRORS          0
+
+#if USE_STDOUT_FOR_ERRORS
+
+static FILE *ErrorOut = stdout ;
+
+#else
+
+static FILE *ErrorOut = stderr ;
+
+#endif
+
+#define ERROR          0
+#define WARNING                1
+
+extern char *filename ;
+extern int lineno ;
+extern int fatalError ;
+
+struct  {
+       int             errType ;
+       char    *errText ;
+} ErrTab [] =
+{
+{  ERROR  ,"error *** Duplicate symbol '%s', symbol IGNORED\n"               },
+{ ERROR  ,"error *** Syntax Error Declaration ingonerd\n"                            },
+{ ERROR  ,"error *** Constant Expected Found Variable\n"                          },
+{ ERROR  ,"error *** 'malloc' failed file '%s' for size %ld\n"               },
+{ ERROR  ,"error *** 'fopen' failed on file '%s'\n"                                  },
+{ ERROR  ,"error *** Internal Error Oclass invalid '%s'\n"                           },
+{ ERROR  ,"error *** Cannot allocate variable '%s'.\n"                       },
+{ ERROR  ,"error *** Old style C declaration. IGNORED '%s'\n"                },
+{ ERROR  ,"error *** Out of stack Space. '%s' not allocted\n"                },
+{ ERROR  ,"error *** FATAL Compiler Internal Error in file '%s' line number '%d' : %s \nContact Author with source code\n" },
+{ ERROR  ,"error *** 'lvalue' required for '%s' operation .\n"               },
+{ ERROR  ,"error *** Creation of temp file failed\n"                         },
+{ ERROR  ,"error *** Function expected here '%s'\n"                                  },
+{ ERROR  ,"error *** 'using', 'interrupt' or 'reentrant' must follow a function definiton .'%s'\n"},
+{ ERROR  ,"error *** Absolute address & initial value both cannot be specified for\n a 'sfr','sbit' storage class, initial value ignored '%s'\n"  },
+{ WARNING,"warning *** Variable in the storage class cannot be initialized.'%s'\n"},
+{ WARNING,"warning *** storage class not allowed for automatic variable '%s' in reentrant function\n"   },
+{ ERROR  ,"error *** absolute address not allowed for automatic var '%s' in reentrant function \n"           },
+{ WARNING,"warning *** Initializer different levels of indirections\n"       },
+{ ERROR  ,"error *** Function name '%s' redefined \n"                        },
+{ ERROR  ,"error *** Undefined identifier '%s'\n"                                 },
+{ WARNING,"warning *** stack exceeds 256 bytes for function '%s'\n"},
+{ ERROR  ,"error *** Array or pointer required for '%s' operation \n"        },
+{ ERROR  ,"error *** Array index not an integer\n"                                },
+{ ERROR  ,"error *** Array bound Exceeded, assuming zero\n"                          },
+{ ERROR  ,"error *** Structure/Union expected left of '.%s'\n"                    },
+{ ERROR  ,"error *** '%s' not a structure/union member\n"                         },
+{ ERROR  ,"error *** Pointer required\n"                                             },
+{ ERROR  ,"error *** 'unary %c': illegal operand\n"                                  },
+{ ERROR  ,"error *** convertion error: integral promotion failed\n"                  },
+{ ERROR  ,"error *** type must be INT for bit field definition\n"                    },
+{ ERROR  ,"error *** bit field size greater than 16 . assuming 16\n"              },
+{ WARNING,"warning *** high order truncation might occur\n"                          },
+{ ERROR  ,"error *** Attempt to assign value to a constant variable %s\n"         },
+{ ERROR  ,"error *** Lvalue specifies constant object\n"                          },
+{ ERROR  ,"error *** '&' illegal operand , %s\n"                                  },
+{ ERROR  ,"error *** illegal cast (cast cannot be aggregate)\n"                   },
+{ ERROR  ,"error *** '*' bad operand\n"                                           },
+{ ERROR  ,"error *** Argument count error, argument ignored\n"                    },
+{ ERROR  ,"error *** Function was expecting more arguments\n"                     },
+{ ERROR  ,"error *** Function name expected '%s'.ANSI style declaration REQUIRED\n"},
+{ ERROR  ,"error *** invalid operand '%s'\n"                                         },
+{ ERROR  ,"error *** pointer + pointer invalid\n"                                    },
+{ ERROR  ,"error *** invalid operand for shift operator\n"                           },
+{ ERROR  ,"error *** compare operand cannot be struct/union\n"               },
+{ ERROR  ,"error *** operand invalid for bitwise operation\n"                },
+{ ERROR  ,"error *** Invalid operand for '&&' or '||'\n"                             },
+{ WARNING,"warning *** indirections to different types %s %s \n"                     },
+{ ERROR  ,"error *** cannot assign values to aggregates\n"                           },
+{ ERROR  ,"error *** bit Arrays can be accessed by literal index only\n"             },
+{ ERROR  ,"error *** Array or Pointer to bit|sbit|sfr not allowed.'%s'\n"            },
+{ ERROR  ,"error *** typedef/enum '%s' duplicate.Previous definiton Ignored\n"    },
+{ ERROR  ,"error *** Actual Argument type different from declaration %d\n"           },
+{ ERROR  ,"error *** Function return value mismatch\n"                       },
+{ ERROR  ,"error *** Function cannot return aggregate. Func body ignored\n"          },
+{ ERROR  ,"error *** ANSI Style declaration needed\n"                        },
+{ ERROR  ,"error *** Label name redefined '%s'\n"                                    },
+{ ERROR  ,"error *** Label undefined '%s'\n"                                 },
+{ ERROR  ,"error *** void function returning value\n"                        },
+{ ERROR  ,"error *** function '%s' must return value\n"                              },
+{ WARNING,"warning *** function return value mismatch\n"                             },
+{ ERROR  ,"error *** 'case/default' found without 'switch'.statement ignored\n"   },
+{ ERROR  ,"error *** 'case' expression not constant. statement ignored\n"            },
+{ ERROR  ,"error *** 'break/continue' statement out of context\n"                    },
+{ ERROR  ,"error *** nonintegral used in switch expression\n"                },
+{ ERROR  ,"error *** function '%s' already has body\n"                       },
+{ ERROR  ,"error *** attempt to allocate variable of unknown size '%s'\n"            },
+{ ERROR  ,"error *** aggregate 'auto' variable '%s' cannot be initialized\n"      },
+{ ERROR  ,"error *** too many initializers\n"                                },
+{ ERROR  ,"error *** struct/union/array '%s' :initialization needs curly braces\n"},
+{ ERROR  ,"error *** non-address initialization expression\n"                },
+{ ERROR  ,"error *** interrupt no '%d' already has a service routine '%s'\n"         },
+{ ERROR  ,"error *** interrupt routine cannot have arguments, arguments ingored\n"},
+{ ERROR  ,"error *** critical compiler #include file missing.          \n"   },
+{ ERROR  ,"error *** function 'main' undefined\n"                                 },
+{ ERROR  ,"error *** 'extern' variable '%s' cannot be initialised      \n"           },
+{ ERROR  ,"error *** Pre-Processor %s\n"                                             },
+{ ERROR  ,"error *** _dup call failed\n"                                          },
+{ WARNING,"warning *** pointer being cast to incompatible type \n"                        },
+{ WARNING,"warning *** 'while' loop with 'zero' constant.loop eliminated\n"          },
+{ WARNING,"warning *** %s expression has NO side effects.expr eliminated\n"          },
+{ WARNING,"warning *** constant value '%s', out of range.\n"                 },
+{ WARNING,"warning *** comparison will either, ALWAYs succeed or ALWAYs fail\n"   },
+{ ERROR  ,"error *** Compiler Terminating , contact author with source\n"            },
+{ WARNING,"warning *** 'auto' variable '%s' may be used before initialization at %s(%d)\n"      },
+{ WARNING,"warning *** in function %s unreferenced %s : '%s'\n"                              },
+{ ERROR  ,"error *** unknown size for operand\n"                                     },
+{ WARNING,"warning *** '%s' 'long' not supported , declared as 'int' .\n"            },
+{ WARNING,"warning *** LITERAL value being cast to '_generic' pointer\n"             },
+{ ERROR  ,"error *** %s '%s' address out of range\n"                                 },
+{ ERROR  ,"error *** storage class CANNOT be specified for bit variable '%s'\n"    },
+{ WARNING,"warning *** extern definition for '%s' mismatches with declaration.\n"  },
+{ WARNING,"warning *** Functions called via pointers must be 'reentrant' to take arguments\n"  },
+{ WARNING,"warning *** type 'double' not supported assuming 'float'\n"               },
+{ WARNING,"warning *** if-statement condition always false.if-statement not generated\n"},
+{ WARNING,"warning *** no 'return' statement found for function '%s'\n"              },
+{ WARNING,"warning *** Pre-Processor %s\n"                                           },
+{ WARNING,"warning *** structure '%s' passed as function argument changed to pointer\n"},
+{ ERROR  ,"error *** conflict with previous definition of '%s' for attribute '%s'\n" },
+{ ERROR  ,"error *** variable '%s' declared in code space must have initialiser\n" },
+{ ERROR  ,"error *** operands not integral for assignment operation\n"            },
+{ ERROR  ,"error *** too many parameters \n"                                      },
+{ ERROR  ,"error *** to few parameters\n"                                         },
+{ ERROR  ,"error *** code not generated for '%s' due to previous errors\n"},
+{ WARNING,"warning *** type mismatch for parameter number %d\n"},
+{ ERROR  ,"error *** invalid float constant '%s'\n"},
+{ ERROR  ,"error *** invalid operand for '%s' operation\n"},
+{ ERROR  ,"error *** switch value not an integer\n"},
+{ ERROR  ,"error *** case label not an integer\n"},
+{ WARNING,"warning *** function '%s' too large for global optimization\n"},
+{ WARNING,"warning *** conditional flow changed by optimizer '%s(%d)':so said EVELYN the modified DOG\n"},
+{ WARNING,"warning *** invalid type specifier for pointer type specifier ignored\n"},
+{ WARNING,"warning *** function '%s' implicit declaration\n"},
+{ WARNING,"warning *** %s"},
+{ WARNING,"info *** %s extended by %d bytes for compiler temp(s) :in function  '%s': %s \n"},
+{ WARNING,"warning *** unknown or unsupported #pragma directive '%s'\n"},
+{ WARNING,"warning *** %s shifting more than size of object changed to zero\n"},
+{ WARNING,"warning *** unknown compiler option '%s' ignored\n"},
+{ WARNING,"warning *** option '%s' no longer supported  '%s' \n"},
+{ WARNING,"warning *** don't know what to do with file '%s'. file extension unsupported\n"},
+{ WARNING,"warning *** cannot compile more than one source file . file '%s' ignored\n"},
+{ WARNING,"info *** function '%s', # edges %d , # nodes %d , cyclomatic complexity %d\n"},
+{ ERROR  ,"error *** dividing by ZERO\n"},
+{ ERROR  ,"error *** function cannot return 'bit'\n"},
+{ ERROR  ,"error *** casting from to type 'void' is illegal\n"},
+{ WARNING,"warning *** constant is out of range %s\n" },
+{ WARNING,"warning *** unreachable code %s(%d)\n"},
+{ WARNING,"warning *** non-pointer type cast to _generic pointer\n"},
+{ WARNING,"warning *** possible code generation error at line %d,\n send source to sandeep.dutta@usa.net\n"},
+{ WARNING,"warning *** pointer types incompatible \n" },
+{ WARNING,"warning *** unknown memory model at %s : %d\n" },
+{ ERROR  ,"error   *** cannot generate code for target '%s'\n"},
+{ WARNING,"warning *** Indirect call to a banked function not implemented.\n"},
+{ WARNING,"warning *** Model '%s' not supported for %s, ignored.\n"},
+{ WARNING,"warning *** Both banked and nonbanked attributes used.  nonbanked wins.\n"},
+{ WARNING,"warning *** Both banked and static used.  static wins.\n"},
+{ WARNING,"warning *** converting integer type to generic pointer: assuming XDATA\n"}
+};
+/*
+-------------------------------------------------------------------------------
+SetErrorOut - Set the error output file
+
+-------------------------------------------------------------------------------
+*/
+
+FILE *SetErrorOut(FILE *NewErrorOut)
+
+{
+ErrorOut = NewErrorOut ;
+
+return NewErrorOut ;
+}
+/*
+-------------------------------------------------------------------------------
+vwerror - Output a standard eror message with variable number of arguements
+
+-------------------------------------------------------------------------------
+*/
+
+void vwerror (int errNum, va_list marker)
+
+{
+if ( ErrTab[errNum].errType == ERROR )
+    fatalError++ ;
+
+if ( filename && lineno ) 
+    fprintf(ErrorOut, "%s(%d):",filename,lineno);
+
+vfprintf(ErrorOut, ErrTab[errNum].errText,marker);
+}
+/*
+-------------------------------------------------------------------------------
+werror - Output a standard eror message with variable number of arguements
+
+-------------------------------------------------------------------------------
+*/
+
+void werror (int errNum, ... )
+
+{
+va_list        marker;
+va_start(marker,errNum);
+vwerror(errNum, marker);
+va_end( marker );
+}
+
index 47df72ee8a1e67ad096c98b00b43aafe63dc1099..fefe22e74f04cd016c0958fa0c28e2c2f97715ed 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include "i386/i386.h" 
 #include "i386/xm-i386.h"
+#define alloca Safe_calloc
 #define bcopy(s, d, n)  memcpy(d, s, n)
 #define bcmp memcmp
 #define bzero(p, l) memset(p, 0, l)
@@ -15,7 +16,7 @@
 #include "i386/xm-linux.h"  
 
 #ifndef __BORLANDC__
-#define alloca malloc
+#define alloca Safe_calloc
 #else
 #include <string.h>
 #include <stdlib.h>
index 4af9bd94453e49d8e3e823c9ae85337291515b1f..23cd61f53cc3b2e3638053ef9da035916b2ba203 100644 (file)
@@ -22,42 +22,42 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  You are forbidden to forbid anyone else to use, share and improve
  what you give them.   Help stamp out software-hoarding!  */
 
-#include "config.h"
-#ifdef HAVE_MALLOC_H
-#include  <malloc.h>
-#endif
-
-static void
-memory_full ()
-{
-  perror ("Memory exhausted.");
-}
-
-char *xmalloc (     unsigned size)
-{
-       register char *ptr = (char *) malloc (size);
-       if (ptr != 0) return (ptr);
-       memory_full ();
-       /*NOTREACHED*/
-       return 0;
-}
-
-char *xrealloc (
-     char *old,
-     unsigned size )
-{
-  register char *ptr = (char *) realloc (old, size);
-  if (ptr == 0)
-    memory_full ();
-  return ptr;
-}
-
-char *xcalloc (
-     unsigned number, unsigned size)
-{
-  register unsigned total = number * size;
-  register char *ptr = (char *) calloc (number, size);
-  if (ptr == 0)
-    memory_full ();
-  return ptr;
-}
+// #include "config.h"
+// #ifdef HAVE_MALLOC_H
+// #include  <malloc.h>
+// #endif
+//
+// static void
+// memory_full ()
+// {
+//   perror ("Memory exhausted.");
+//}
+//
+// char *xmalloc (     unsigned size)
+// {
+//  register char *ptr = (char *) malloc (size);
+//  if (ptr != 0) return (ptr);
+//  memory_full ();
+  /*NOTREACHED*/
+//  return 0;
+// }
+//
+// char *xrealloc (
+//      char *old,
+//      unsigned size )
+// {
+//   register char *ptr = (char *) realloc (old, size);
+//   if (ptr == 0)
+//     memory_full ();
+//   return ptr;
+// }
+//
+// char *xcalloc (
+//      unsigned number, unsigned size)
+// {
+//   register unsigned total = number * size;
+//   register char *ptr = (char *) calloc (number, size);
+//   if (ptr == 0)
+//     memory_full ();
+//   return ptr;
+// }
index 54fb434b3a1d9747a6f52449d0b17bedb0ec47ce..9dc3b874625b4ccbfcfae2470f87e9787629687f 100644 (file)
@@ -24,15 +24,17 @@ Written by Per Bothner 1994. */
 
 /* Parse a C expression from text in a string  */
 
-#if defined(_MSC_VER)
-#include <malloc.h>
-#endif
+//#if defined(_MSC_VER)
+//#include <malloc.h>
+//#endif
 
 #include "config.h"   
 #include "cpplib.h"
 
-extern char *xmalloc PARAMS ((unsigned));
-extern char *xrealloc PARAMS ((char *, unsigned));
+#include "newalloc.h"
+
+//extern char *xmalloc PARAMS ((unsigned));
+//extern char *xrealloc PARAMS ((char *, unsigned));
 
 #ifdef MULTIBYTE_CHARS
 #include <stdlib.h>
@@ -68,7 +70,7 @@ struct arglist {
 #define NULL_PTR ((GENERIC_PTR)0)
 #endif
 
-extern char *xmalloc ();
+//extern char *xmalloc ();
 
 #ifndef CHAR_TYPE_SIZE
 #define CHAR_TYPE_SIZE BITS_PER_UNIT
@@ -979,10 +981,10 @@ cpp_parse_expr (
          int old_size = (char*)limit - (char*)stack;
          int new_size = 2 * old_size;
          if (stack != init_stack)
-           new_stack = (struct operation*) xrealloc (stack, new_size);
+           new_stack = (struct operation*) Safe_realloc (stack, new_size);
          else
            {
-             new_stack = (struct operation*) xmalloc (new_size);
+             new_stack = (struct operation*) Safe_malloc (new_size);
              bcopy ((char *) stack, (char *) new_stack, old_size);
            }
          stack = new_stack;
index e9645aa68f5ea2e33aaf18495fdda874aee8a7de..d9a3dca1f8b6a6ff8d56e59c318877b90b8b0a60 100644 (file)
@@ -24,7 +24,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 #include "cpplib.h"
 #include "cpphash.h"
-extern char *xmalloc PARAMS ((unsigned));
+//extern char *xmalloc PARAMS ((unsigned));
+
+#include "newalloc.h"
+
+#if defined(_MSC_VER)
+#include <string.h>
+#include <stdlib.h>
+#endif
 
 /* Define a generic NULL if one hasn't already been defined.  */
 
@@ -177,7 +184,7 @@ install (
     hash = hashf (name, len, HASHSIZE);
 
   i = sizeof (HASHNODE) + len + 1;
-  hp = (HASHNODE *) xmalloc (i);
+  hp = (HASHNODE *) Safe_malloc (i);
   bucket = hash;
   hp->bucket_hdr = &hashtab[bucket];
   hp->next = hashtab[bucket];
index c395b83490df77e775e4fd84eab9f7d5b6153214..4efe80df1f13d45509505e2443579f40a044da63 100644 (file)
@@ -48,7 +48,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    for the sake of machines with limited C compilers.  */
 #ifndef EMACS
 #include "config.h"
-#include <malloc.h>
+#include "newalloc.h"
 #include <string.h>
 #endif /* not EMACS */
 #define GCC_INCLUDE_DIR "/usr/local/lib/gcc-lib/i386-unknown-freebsd_1.0/2.5.8/include"
@@ -272,7 +272,7 @@ struct cpp_pending {
 
 /* Forward declarations.  */
 
-extern char *xmalloc ();
+//extern char *Safe_malloc ();
 
 static void add_import ();
 static void append_include_chain ();
@@ -313,8 +313,8 @@ static int safe_read ();
 static void push_macro_expansion PARAMS ((cpp_reader *,
                                          U_CHAR*, int, HASHNODE*));
 static struct cpp_pending *nreverse_pending PARAMS ((struct cpp_pending*));
-extern char *xrealloc ();
-extern char *xcalloc ();
+//extern char *xrealloc ();
+//extern char *xcalloc ();
 static char *savestring ();
 
 static void conditional_skip ();
@@ -558,8 +558,7 @@ cpp_grow_buffer (
 {
   long old_written = CPP_WRITTEN (pfile);
   pfile->token_buffer_size = n + 2 * pfile->token_buffer_size;
-  pfile->token_buffer = (U_CHAR*)
-    xrealloc(pfile->token_buffer, pfile->token_buffer_size);
+  pfile->token_buffer = (U_CHAR*) Safe_realloc(pfile->token_buffer, pfile->token_buffer_size);
   CPP_SET_WRITTEN (pfile, old_written);
 }
 
@@ -733,7 +732,7 @@ deps_output (
   if (pfile->deps_size + size + 8 > pfile->deps_allocated_size)
     {
       pfile->deps_allocated_size = (pfile->deps_size + size + 50) * 2;
-      pfile->deps_buffer = (char *) xrealloc (pfile->deps_buffer,
+      pfile->deps_buffer = (char *) Safe_realloc(pfile->deps_buffer,
                                              pfile->deps_allocated_size);
     }
   if (spacer == ' ' && pfile->deps_column > 0)
@@ -768,18 +767,18 @@ path_include (
       while (*q != 0 && *q != PATH_SEPARATOR) q++;
       if (p == q) {
        /* An empty name in the path stands for the current directory.  */
-       name = (char *) xmalloc (2);
+       name = (char *) Safe_malloc (2);
        name[0] = '.';
        name[1] = 0;
       } else {
        /* Otherwise use the directory that is named.  */
-       name = (char *) xmalloc (q - p + 1);
+       name = (char *) Safe_malloc (q - p + 1);
        bcopy (p, name, q - p);
        name[q - p] = 0;
       }
 
       dirtmp = (struct file_name_list *)
-       xmalloc (sizeof (struct file_name_list));
+       Safe_malloc (sizeof (struct file_name_list));
       dirtmp->next = 0;                /* New one goes on the end */
       dirtmp->control_macro = 0;
       dirtmp->c_system_include_path = 0;
@@ -1287,7 +1286,7 @@ collect_expansion (
   while (p < limit)
     if (*p++ == '@')
       maxsize++;
-  defn = (DEFINITION *) xcalloc (1, maxsize);
+  defn = (DEFINITION *) Safe_calloc(maxsize);
 
   defn->nargs = nargs;
   exp_p = defn->expansion = (U_CHAR *) defn + sizeof (DEFINITION);
@@ -1450,7 +1449,7 @@ collect_expansion (
              break;
            /* make a pat node for this arg and append it to the end of
               the pat list */
-           tpat = (struct reflist *) xmalloc (sizeof (struct reflist));
+           tpat = (struct reflist *) Safe_malloc (sizeof (struct reflist));
            tpat->next = NULL;
            tpat->raw_before = concat == id_beg;
            tpat->raw_after = 0;
@@ -1513,7 +1512,7 @@ collect_expansion (
 #if 0
 /* This isn't worth the time it takes.  */
   /* give back excess storage */
-  defn->expansion = (U_CHAR *) xrealloc (defn->expansion, defn->length + 1);
+  defn->expansion = (U_CHAR *) Safe_realloc(defn->expansion, defn->length + 1);
 #endif
 
   return defn;
@@ -1647,7 +1646,7 @@ create_definition (
     /* Now set defn->args.argnames to the result of concatenating
        the argument names in reverse order
        with comma-space between them.  */
-    defn->args.argnames = (U_CHAR *) xmalloc (arglengths + 1);
+    defn->args.argnames = (U_CHAR *) Safe_malloc (arglengths + 1);
     {
       struct arglist *temp;
       int i = 0;
@@ -1929,7 +1928,7 @@ cpp_push_buffer (
   bzero ((char *) buf, sizeof (cpp_buffer));
   CPP_BUFFER (pfile) = buf;
 #else
-  register cpp_buffer *buf = (cpp_buffer*) xmalloc (sizeof(cpp_buffer));
+  register cpp_buffer *buf = (cpp_buffer*) Safe_malloc (sizeof(cpp_buffer));
   bzero ((char *) buf, sizeof (cpp_buffer));
   CPP_PREV_BUFFER (buf) = CPP_BUFFER (pfile);
   CPP_BUFFER (pfile) = buf;
@@ -2924,7 +2923,7 @@ macroexpand (
            args[ap->argno].use_count++;
        }
 
-      xbuf = (U_CHAR *) xmalloc (xbuf_len + 1);
+      xbuf = (U_CHAR *) Safe_malloc (xbuf_len + 1);
 
       /* Generate in XBUF the complete expansion
         with arguments substituted in.
@@ -3327,7 +3326,7 @@ do_include (
 
   /* Allocate this permanently, because it gets stored in the definitions
      of macros.  */
-  fname = (char *) xmalloc (pfile->max_include_len + flen + 4);
+  fname = (char *) Safe_malloc (pfile->max_include_len + flen + 4);
   /* + 2 above for slash and terminating null.  */
   /* + 2 added for '.h' on VMS (to support '#include filename') */
 
@@ -3479,7 +3478,7 @@ do_include (
       /* This is the first time for this file.  */
       /* Add it to list of files included.  */
 
-      ptr = (struct file_name_list *) xmalloc (sizeof (struct file_name_list));
+      ptr = (struct file_name_list *) Safe_malloc (sizeof (struct file_name_list));
       ptr->control_macro = 0;
       ptr->c_system_include_path = 0;
       ptr->next = pfile->all_include_files;
@@ -3639,7 +3638,7 @@ assertion_install (
   register U_CHAR *p, *q;
 
   i = sizeof (ASSERTION_HASHNODE) + len + 1;
-  hp = (ASSERTION_HASHNODE *) xmalloc (i);
+  hp = (ASSERTION_HASHNODE *) Safe_malloc (i);
   bucket = hash;
   hp->bucket_hdr = &pfile->assertion_hashtab[bucket];
   hp->next = pfile->assertion_hashtab[bucket];
@@ -3867,7 +3866,7 @@ do_line (
       }
     if (hp == 0) {
       /* Didn't find it; cons up a new one.  */
-      hp = (HASHNODE *) xcalloc (1, sizeof (HASHNODE) + fname_length + 1);
+      hp = (HASHNODE *) Safe_calloc(sizeof (HASHNODE) + fname_length + 1);
       hp->next = *hash_bucket;
       *hash_bucket = hp;
 
@@ -3947,7 +3946,7 @@ do_error (
      U_CHAR *buf,U_CHAR *limit)
 {
   int length = limit - buf;
-  U_CHAR *copy = (U_CHAR *) xmalloc (length + 1);
+  U_CHAR *copy = (U_CHAR *) Safe_malloc (length + 1);
   bcopy (buf, copy, length);
   copy[length] = 0;
   SKIP_WHITE_SPACE (copy);
@@ -3968,7 +3967,7 @@ do_warning (
      U_CHAR *buf,U_CHAR *limit)
 {
   int length = limit - buf;
-  U_CHAR *copy = (U_CHAR *) xmalloc (length + 1);
+  U_CHAR *copy = (U_CHAR *) Safe_malloc (length + 1);
   bcopy (buf, copy, length);
   copy[length] = 0;
   SKIP_WHITE_SPACE (copy);
@@ -3995,7 +3994,7 @@ do_once (
     }
 
     
-  new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list));
+  new = (struct file_name_list *) Safe_malloc (sizeof (struct file_name_list));
   new->next = pfile->dont_repeat_files;
   pfile->dont_repeat_files = new;
   new->fname = savestring (ip->fname);
@@ -4250,7 +4249,7 @@ do_xifdef (
       skip = (hp == NULL) ^ (keyword->type == T_IFNDEF);
       if (start_of_file && !skip)
        {
-         control_macro = (U_CHAR *) xmalloc (ident_length + 1);
+         control_macro = (U_CHAR *) Safe_malloc (ident_length + 1);
          bcopy (ident, control_macro, ident_length + 1);
        }
     }
@@ -4302,7 +4301,7 @@ conditional_skip (
 {
   IF_STACK_FRAME *temp;
 
-  temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME));
+  temp = (IF_STACK_FRAME *) Safe_calloc(sizeof (IF_STACK_FRAME));
   temp->fname = CPP_BUFFER (pfile)->nominal_fname;
 #if 0
   temp->lineno = CPP_BUFFER (pfile)->lineno;
@@ -4397,7 +4396,7 @@ skip_if_group (
                case T_IFDEF:
                case T_IFNDEF:
                  temp
-                   = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME));
+                   = (IF_STACK_FRAME *) Safe_calloc(sizeof (IF_STACK_FRAME));
                  temp->next = pfile->if_stack;
                  pfile->if_stack = temp;
 #if 0
@@ -5195,7 +5194,7 @@ cpp_get_token (
              CPP_SET_WRITTEN (pfile, before_name_written);
              special_symbol (hp, pfile);
              xbuf_len = CPP_WRITTEN (pfile) - before_name_written;
-             xbuf = (U_CHAR *) xmalloc (xbuf_len + 1);
+             xbuf = (U_CHAR *) Safe_malloc (xbuf_len + 1);
              CPP_SET_WRITTEN (pfile, before_name_written);
              bcopy (CPP_PWRITTEN (pfile), xbuf, xbuf_len + 1);
              push_macro_expansion (pfile, xbuf, xbuf_len, hp);
@@ -5390,8 +5389,8 @@ add_import (
 
   hashval = import_hash (fname);
   fstat (fd, &sb);
-  i = (struct import_file *)xmalloc (sizeof (struct import_file));
-  i->name = (char *)xmalloc (strlen (fname)+1);
+  i = (struct import_file *)Safe_malloc (sizeof (struct import_file));
+  i->name = (char *)Safe_malloc (strlen (fname)+1);
   strcpy (i->name, fname);
   bcopy ((char *) &sb.st_ino, (char *) &i->inode, sizeof (sb.st_ino));
   i->dev = sb.st_dev;
@@ -5428,7 +5427,7 @@ read_filename_string (
   int len;
 
   len = 20;
-  set = alloc = xmalloc (len + 1);
+  set = alloc = Safe_malloc (len + 1);
   if (! is_space[ch])
     {
       *set++ = ch;
@@ -5437,7 +5436,7 @@ read_filename_string (
          if (set - alloc == len)
            {
              len *= 2;
-             alloc = xrealloc (alloc, len + 1);
+             alloc = Safe_realloc(alloc, len + 1);
              set = alloc + len / 2;
            }
          *set++ = ch;
@@ -5473,7 +5472,7 @@ read_name_map (
       return map_list_ptr->map_list_map;
 
   map_list_ptr = ((struct file_name_map_list *)
-                 xmalloc (sizeof (struct file_name_map_list)));
+                 Safe_malloc (sizeof (struct file_name_map_list)));
   map_list_ptr->map_list_name = savestring (dirname);
   map_list_ptr->map_list_map = NULL;
 
@@ -5503,7 +5502,7 @@ read_name_map (
          to = read_filename_string (ch, f);
 
          ptr = ((struct file_name_map *)
-                xmalloc (sizeof (struct file_name_map)));
+                Safe_malloc (sizeof (struct file_name_map)));
          ptr->map_from = from;
 
          /* Make the real filename absolute.  */
@@ -5511,7 +5510,7 @@ read_name_map (
            ptr->map_to = to;
          else
            {
-             ptr->map_to = xmalloc (dirlen + strlen (to) + 2);
+             ptr->map_to = Safe_malloc (dirlen + strlen (to) + 2);
              strcpy (ptr->map_to, dirname);
              ptr->map_to[dirlen] = '/';
              strcpy (ptr->map_to + dirlen + 1, to);
@@ -5654,7 +5653,7 @@ finclude (
   fp->cleanup = file_cleanup;
 
   if (S_ISREG (st_mode)) {
-    fp->buf = (U_CHAR *) xmalloc (st_size + 2);
+    fp->buf = (U_CHAR *) Safe_malloc (st_size + 2);
     fp->alimit = fp->buf + st_size + 2;
     fp->cur = fp->buf;
 
@@ -5676,7 +5675,7 @@ finclude (
     int bsize = 2000;
 
     st_size = 0;
-    fp->buf = (U_CHAR *) xmalloc (bsize + 2);
+    fp->buf = (U_CHAR *) Safe_malloc (bsize + 2);
 
     for (;;) {
       i = safe_read (f, fp->buf + st_size, bsize - st_size);
@@ -5686,7 +5685,7 @@ finclude (
       if (st_size != bsize)
        break;  /* End of file */
       bsize *= 2;
-      fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2);
+      fp->buf = (U_CHAR *) Safe_realloc(fp->buf, bsize + 2);
     }
     fp->cur = fp->buf;
     length = st_size;
@@ -5912,7 +5911,7 @@ push_parse_file (
        if (*startp == PATH_SEPARATOR)
          num_dirs++;
       include_defaults
-       = (struct default_include *) xmalloc ((num_dirs
+       = (struct default_include *) Safe_malloc ((num_dirs
                                               * sizeof (struct default_include))
                                              + sizeof (include_defaults_array));
       startp = endp = epath;
@@ -5970,9 +5969,9 @@ push_parse_file (
          if (!strncmp (p->fname, default_prefix, default_len)) {
            /* Yes; change prefix and add to search list.  */
            struct file_name_list *new
-             = (struct file_name_list *) xmalloc (sizeof (struct file_name_list));
+             = (struct file_name_list *) Safe_malloc (sizeof (struct file_name_list));
            int this_len = strlen (specd_prefix) + strlen (p->fname) - default_len;
-           char *str = (char *) xmalloc (this_len + 1);
+           char *str = (char *) Safe_malloc (this_len + 1);
            strcpy (str, specd_prefix);
            strcat (str, p->fname + default_len);
            new->fname = str;
@@ -5991,7 +5990,7 @@ push_parse_file (
       if (!p->cplusplus
          || (opts->cplusplus && !opts->no_standard_cplusplus_includes)) {
        struct file_name_list *new
-         = (struct file_name_list *) xmalloc (sizeof (struct file_name_list));
+         = (struct file_name_list *) Safe_malloc (sizeof (struct file_name_list));
        new->control_macro = 0;
        new->c_system_include_path = !p->cxx_aware;
        new->fname = p->fname;
@@ -6084,7 +6083,7 @@ push_parse_file (
     if (*s != 0)
       {
        opts->deps_target = s + 1;
-       output_file = (char *) xmalloc (s - spec + 1);
+       output_file = (char *) Safe_malloc (s - spec + 1);
        bcopy (spec, output_file, s - spec);
        output_file[s - spec] = 0;
       }
@@ -6103,7 +6102,7 @@ push_parse_file (
   if (opts->print_deps)
     {
       pfile->deps_allocated_size = 200;
-      pfile->deps_buffer = (char *) xmalloc (pfile->deps_allocated_size);
+      pfile->deps_buffer = (char *) Safe_malloc (pfile->deps_allocated_size);
       pfile->deps_buffer[0] = 0;
       pfile->deps_size = 0;
       pfile->deps_column = 0;
@@ -6244,7 +6243,7 @@ init_parse_file (
   pfile->get_token = cpp_get_token;
 
   pfile->token_buffer_size = 200;
-  pfile->token_buffer = (U_CHAR*)xmalloc (pfile->token_buffer_size);
+  pfile->token_buffer = (U_CHAR*)Safe_malloc (pfile->token_buffer_size);
   CPP_SET_WRITTEN (pfile, 0);
 
   pfile->system_include_depth = 0;
@@ -6278,7 +6277,7 @@ push_pending (
      char *arg)
 {
   struct cpp_pending *pend
-    = (struct cpp_pending*)xmalloc (sizeof (struct cpp_pending));
+    = (struct cpp_pending*)Safe_malloc (sizeof (struct cpp_pending));
   pend->cmd = cmd;
   pend->arg = arg;
   pend->next = CPP_OPTIONS (pfile)->pending;
@@ -6333,11 +6332,11 @@ cpp_handle_options (
                                                fatal ("Filename missing after `-isystem' option");
                                        
                                        dirtmp = (struct file_name_list *)
-                                               xmalloc (sizeof (struct file_name_list));
+                                               Safe_malloc (sizeof (struct file_name_list));
                                        dirtmp->next = 0;
                                        dirtmp->control_macro = 0;
                                        dirtmp->c_system_include_path = 1;
-                                       dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) + 1);
+                                       dirtmp->fname = (char *) Safe_malloc (strlen (argv[i+1]) + 1);
                                        strcpy (dirtmp->fname, argv[++i]);
                                        dirtmp->got_name_map = 0;
                                        
@@ -6363,14 +6362,14 @@ cpp_handle_options (
                                        }
                                        
                                        dirtmp = (struct file_name_list *)
-                                               xmalloc (sizeof (struct file_name_list));
+                                               Safe_malloc (sizeof (struct file_name_list));
                                        dirtmp->next = 0;       /* New one goes on the end */
                                        dirtmp->control_macro = 0;
                                        dirtmp->c_system_include_path = 0;
                                        if (i + 1 == argc)
                                                fatal ("Directory name missing after `-iwithprefix' option");
                                        
-                                       dirtmp->fname = (char *) xmalloc (strlen (argv[i+1])
+                                       dirtmp->fname = (char *) Safe_malloc (strlen (argv[i+1])
                                                + strlen (prefix) + 1);
                                        strcpy (dirtmp->fname, prefix);
                                        strcat (dirtmp->fname, argv[++i]);
@@ -6398,14 +6397,14 @@ cpp_handle_options (
                                        }
                                        
                                        dirtmp = (struct file_name_list *)
-                                               xmalloc (sizeof (struct file_name_list));
+                                               Safe_malloc (sizeof (struct file_name_list));
                                        dirtmp->next = 0;       /* New one goes on the end */
                                        dirtmp->control_macro = 0;
                                        dirtmp->c_system_include_path = 0;
                                        if (i + 1 == argc)
                                                fatal ("Directory name missing after `-iwithprefixbefore' option");
                                        
-                                       dirtmp->fname = (char *) xmalloc (strlen (argv[i+1])
+                                       dirtmp->fname = (char *) Safe_malloc (strlen (argv[i+1])
                                                + strlen (prefix) + 1);
                                        strcpy (dirtmp->fname, prefix);
                                        strcat (dirtmp->fname, argv[++i]);
@@ -6418,7 +6417,7 @@ cpp_handle_options (
                                        struct file_name_list *dirtmp;
                                        
                                        dirtmp = (struct file_name_list *)
-                                               xmalloc (sizeof (struct file_name_list));
+                                               Safe_malloc (sizeof (struct file_name_list));
                                        dirtmp->next = 0;       /* New one goes on the end */
                                        dirtmp->control_macro = 0;
                                        dirtmp->c_system_include_path = 0;
@@ -6701,7 +6700,7 @@ cpp_handle_options (
                                                        }
                                                        else {
                                                                dirtmp = (struct file_name_list *)
-                                                                       xmalloc (sizeof (struct file_name_list));
+                                                                       Safe_malloc (sizeof (struct file_name_list));
                                                                dirtmp->next = 0;               /* New one goes on the end */
                                                                dirtmp->control_macro = 0;
                                                                dirtmp->c_system_include_path = 0;
@@ -6903,7 +6902,7 @@ do_assert (
     U_CHAR *symname = pfile->token_buffer + symstart;
     int hashcode = hashf (symname, sym_length, ASSERTION_HASHSIZE);
     struct tokenlist_list *value
-      = (struct tokenlist_list *) xmalloc (sizeof (struct tokenlist_list));
+      = (struct tokenlist_list *) Safe_malloc (sizeof (struct tokenlist_list));
 
     hp = assertion_lookup (pfile, symname, sym_length, hashcode);
     if (hp == NULL) {
@@ -7154,7 +7153,7 @@ read_token_list (
 
       length = CPP_WRITTEN (pfile) - name_written;
       temp = (struct arglist *)
-         xmalloc (sizeof (struct arglist) + length + 1);
+         Safe_malloc (sizeof (struct arglist) + length + 1);
       temp->name = (U_CHAR *) (temp + 1);
       bcopy ((char *) (pfile->token_buffer + name_written),
             (char *) temp->name, length);
@@ -7242,7 +7241,7 @@ savestring (
      char *input)
 {
   unsigned size = strlen (input);
-  char *output = xmalloc (size + 1);
+  char *output = Safe_malloc (size + 1);
   strcpy (output, input);
   return output;
 }
@@ -7538,7 +7537,7 @@ cpp_error_from_errno (
   if (ip != NULL)
     cpp_file_line_for_message (pfile, ip->nominal_fname, ip->lineno, -1);
 
-  cpp_message (pfile, 1, "%s: %s", name, my_strerror (errno));
+  cpp_message (pfile, 1, "%s: %s", name, my_strerror (errno),NULL);
 }
 
 void
index 321e157a1e1aa3275ec6de348d056a3d07b8b4f1..7787f7d84d20005398c7fdf1d04e1a6c958e7294 100644 (file)
@@ -646,6 +646,36 @@ extern cpp_buffer* cpp_pop_buffer PARAMS ((cpp_reader *));
 extern cpp_hashnode* cpp_lookup PARAMS ((cpp_reader*, const U_CHAR*,
                                         int, int));
 
+/* Define the MS VC6 stuff - Some of these should also be defined for
+the other hosts but they are here until declared safe for all */
+
+#if defined(_MSC_VER)
+
+void init_parse_file (cpp_reader *pfile) ;
+
+void init_parse_options (struct cpp_options *opts) ;
+
+int push_parse_file (cpp_reader *pfile,char *fname) ;
+
+void cpp_finish (cpp_reader *pfile) ;
+
+void cpp_hash_cleanup (cpp_reader *pfile) ;
+
+void cpp_file_line_for_message (cpp_reader *pfile,char *filename ,int line, int column) ;
+
+void cpp_print_containing_files (cpp_reader *pfile) ;
+
+void cpp_message (cpp_reader *pfile,int is_error,char *msg,char *arg1, char *arg2, char *arg3) ;
+
+void skip_rest_of_line (cpp_reader *pfile) ;
+
+/* Parse an identifier starting with C. */
+
+int parse_name (cpp_reader *pfile, int c) ;
+
+#endif
+
+
 #ifdef __cplusplus
 }
 #endif
index 3cfc66eb3008efaf14915fc0433678a3141a0fa4..1cb018803ec504773a6ac6c43d9fd04dcf41643a 100644 (file)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /J /FD /c
+# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
 # SUBTRACT CPP /WX
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
@@ -68,16 +68,15 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c
-# SUBTRACT CPP /WX
+# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I "..\util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"./" /J /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
+# ADD BSC32 /nologo /o".\sdcpp.bsc"
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /out:"..\..\bin\sdcpp.exe" /pdbtype:sept
+# ADD LINK32 /nologo /version:2.2 /subsystem:console /debug /machine:I386 /out:"..\..\bin\sdcpp.exe" /pdbtype:sept
 # SUBTRACT LINK32 /incremental:no
 
 !ENDIF 
@@ -113,6 +112,10 @@ SOURCE=cpplib.c
 
 SOURCE=cppmain.c
 # End Source File
+# Begin Source File
+
+SOURCE=..\Util\NewAlloc.c
+# End Source File
 # End Group
 # Begin Group "Header Files"
 
@@ -131,6 +134,10 @@ SOURCE=.\cpplib.h
 # End Source File
 # Begin Source File
 
+SOURCE=..\Util\newalloc.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\tm.h
 # End Source File
 # End Group