diff --git a/ChangeLog b/ChangeLog index 62ad88c3f..ffe61c9d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-01-09 Dietmar Warning + * src/misc/alloc.c, src/frontend/outitf.c: heap only needed under windows for zoom + 2009-01-05 Dietmar Warning * src/math/misc/isinf.c, isnan.c, src/include/missing_math.h: small polish for HAVE_DECL_XXX macros, more elaborate isinf function diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index f71eb6ca1..53be1bdec 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -66,7 +66,7 @@ static void freeRun(runDesc *run); /* plot output data shall go into extra heap to prevent massive memory fragmentation of standard process heap */ -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined HAS_WINDOWS && (defined(_MSC_VER) || defined(__MINGW32__)) #define newrealloc hrealloc #else #define newrealloc trealloc diff --git a/src/misc/alloc.c b/src/misc/alloc.c index 719e673d5..d712464c0 100644 --- a/src/misc/alloc.c +++ b/src/misc/alloc.c @@ -6,25 +6,22 @@ $Id$ /* * Memory alloction functions */ -#include +#include "ngspice.h" #ifndef HAVE_LIBGC -#include -#include -#include /*saj For Tcl module locking*/ #ifdef TCL_MODULE #include -//#include #endif - +#ifdef HAS_WINDOWS #if defined(_MSC_VER) || defined(__MINGW32__) #undef BOOLEAN #include extern HANDLE outheap; #endif +#endif /* Malloc num bytes and initialize to zero. Fatal error if the space can't * be tmalloc'd. Return NULL for a request for 0 bytes. @@ -59,6 +56,54 @@ tmalloc(size_t num) return(s); } +/* Original Berkeley Implementation */ +/* +void * +tmalloc(size_t num) +{ + void *s; + + if (!num) + return NULL; + + s = malloc((unsigned) num); + if (!s) { + fprintf(stderr, + "malloc: Internal Error: can't allocate %d bytes.\n", num); + exit(EXIT_BAD); + } + + bzero(s, num); + + return(s); +} + +void * +trealloc(void *str, size_t num) +{ + void *s; + + if (!num) { + if (str) + free(str); + return NULL; + } + + if (!str) + s = tmalloc(num); + else + s = realloc(str, (unsigned) num); + + if (!s) { + fprintf(stderr, + "realloc: Internal Error: can't allocate %d bytes.\n", num); + exit(EXIT_BAD); + } + return(s); +} + +*/ + void * trealloc(void *ptr, size_t num) { @@ -98,6 +143,7 @@ trealloc(void *ptr, size_t num) Function is used in outitf.c to prevent heap fragmentation An additional heap outheap is used to store the plot output data. */ +#ifdef HAS_WINDOWS #if defined(_MSC_VER) || defined(__MINGW32__) void * hrealloc(void *ptr, size_t num) @@ -134,56 +180,7 @@ hrealloc(void *ptr, size_t num) return(s); } #endif - - - -/* Original Berkeley Implementation */ -/* -void * -tmalloc(size_t num) -{ - void *s; - - if (!num) - return NULL; - - s = malloc((unsigned) num); - if (!s) { - fprintf(stderr, - "malloc: Internal Error: can't allocate %d bytes.\n", num); - exit(EXIT_BAD); - } - - bzero(s, num); - - return(s); -} - -void * -trealloc(void *str, size_t num) -{ - void *s; - - if (!num) { - if (str) - free(str); - return NULL; - } - - if (!str) - s = tmalloc(num); - else - s = realloc(str, (unsigned) num); - - if (!s) { - fprintf(stderr, - "realloc: Internal Error: can't allocate %d bytes.\n", num); - exit(EXIT_BAD); - } - return(s); -} - -*/ +#endif void