- fix memory leaks

- avoid unnecessary mallocs by having a first alloc to do th ework.
This commit is contained in:
Vítor Santos Costa II
2010-04-15 22:23:54 +01:00
parent e231aea1b4
commit c4b12d5cbe
11 changed files with 203 additions and 90 deletions

View File

@@ -122,9 +122,7 @@ static char * my_realloc(char *ptr, UInt sz, UInt osz, int safe)
long long unsigned int mallocs, reallocs, frees;
long long unsigned int tmalloc;
#if DEBUG
#define INSTRUMENT_MALLOC 1
#endif
#undef INSTRUMENT_MALLOC
static inline char *
@@ -264,7 +262,6 @@ Yap_InitPreAllocCodeSpace(void)
return(NULL);
}
#if INSTRUMENT_MALLOC
fprintf(stderr,"vsc ptr=%p\n",ptr);
sz -= sizeof(CELL);
*(CELL*)ptr = sz;
ptr += sizeof(CELL);
@@ -308,7 +305,6 @@ Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe)
reallocs++;
tmalloc -= ScratchPad.sz;
tmalloc += sz;
fprintf(stderr,"vsc ptr=%p\n",ScratchPad.ptr);
#endif
if (!(ptr = my_realloc(ScratchPad.ptr, sz, ScratchPad.sz, safe))) {
Yap_PrologMode &= ~MallocMode;