Browse Source

heap only needed under windows

pre-master-46
dwarning 17 years ago
parent
commit
bea58219e7
  1. 3
      ChangeLog
  2. 2
      src/frontend/outitf.c
  3. 109
      src/misc/alloc.c

3
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

2
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

109
src/misc/alloc.c

@ -6,25 +6,22 @@ $Id$
/*
* Memory alloction functions
*/
#include <config.h>
#include "ngspice.h"
#ifndef HAVE_LIBGC
#include <ngspice.h>
#include <stdio.h>
#include <memory.h>
/*saj For Tcl module locking*/
#ifdef TCL_MODULE
#include <tcl.h>
//#include <tclDecls.h>
#endif
#ifdef HAS_WINDOWS
#if defined(_MSC_VER) || defined(__MINGW32__)
#undef BOOLEAN
#include <windows.h>
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

Loading…
Cancel
Save