to ease replacement of the underlying allocator used by stgMallocBytes() and friends, provide (&use) RtsUtils.c:stgFree()
#endif
*((unsigned char*)ptr) = '\0';
- free(ptr);
+ stgFree(ptr);
}
/* -----------------------------------------------------------------------------
- $Id: Arena.c,v 1.5 2003/02/18 05:40:20 sof Exp $
+ $Id: Arena.c,v 1.6 2003/03/25 17:58:47 sof Exp $
(c) The University of Glasgow 2001
Arena allocation. Arenas provide fast memory allocation at the
ASSERT(arena_blocks >= 0);
freeGroup(bd);
}
- free(arena);
+ stgFree(arena);
}
unsigned long
/*-----------------------------------------------------------------------------
- * $Id: Hash.c,v 1.9 2002/07/17 09:21:49 simonmar Exp $
+ * $Id: Hash.c,v 1.10 2003/03/25 17:58:47 sof Exp $
*
* (c) The AQUA Project, Glasgow University, 1995-1998
* (c) The GHC Team, 1999
}
index--;
}
- free(table->dir[segment]);
+ stgFree(table->dir[segment]);
segment--;
index = HSEGSIZE - 1;
}
- free(table);
+ stgFree(table);
}
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Linker.c,v 1.115 2003/02/21 05:34:15 sof Exp $
+ * $Id: Linker.c,v 1.116 2003/03/25 17:58:47 sof Exp $
*
* (c) The GHC Team, 2000, 2001
*
sprintf(buf, "%s.DRV", dll_name); // KAA: allow loading of drivers (like winspool.drv)
instance = LoadLibrary(buf);
if (instance == NULL) {
- free(buf);
+ stgFree(buf);
/* LoadLibrary failed; return a ptr to the error msg. */
return "addDLL: unknown error";
}
}
- free(buf);
+ stgFree(buf);
/* Add this DLL to the list of DLLs in which to search for symbols. */
o_dll = stgMallocBytes( sizeof(OpenedDLL), "addDLL" );
# elif defined(OBJFORMAT_MACHO)
oc->formatName = "Mach-O";
# else
- free(oc);
+ stgFree(oc);
barf("loadObj: not implemented on this platform");
# endif
/* We're going to leave this in place, in case there are
any pointers from the heap into it: */
- /* free(oc->image); */
- free(oc->fileName);
- free(oc->symbols);
- free(oc->sections);
+ /* stgFree(oc->image); */
+ stgFree(oc->fileName);
+ stgFree(oc->symbols);
+ stgFree(oc->sections);
/* The local hash table should have been freed at the end
of the ocResolve_ call on it. */
ASSERT(oc->lochash == NULL);
- free(oc);
+ stgFree(oc);
return 1;
}
}
/* -----------------------------------------------------------------------------
- * $Id: Printer.c,v 1.56 2003/03/25 17:23:05 sof Exp $
+ * $Id: Printer.c,v 1.57 2003/03/25 17:58:48 sof Exp $
*
* (c) The GHC Team, 1994-2000.
*
}
}
- free(symbol_table);
+ stgFree(symbol_table);
}
prepare_table();
}
/* -----------------------------------------------------------------------------
- * $Id: RetainerSet.c,v 1.3 2002/07/18 09:12:36 simonmar Exp $
+ * $Id: RetainerSet.c,v 1.4 2003/03/25 17:58:49 sof Exp $
*
* (c) The GHC Team, 2001
* Author: Sungwoo Park
fprintf(prof_file, "}\n");
}
- free(rsArray);
+ stgFree(rsArray);
}
#endif // SECOND_APPROACH
/* -----------------------------------------------------------------------------
- * $Id: RtsUtils.c,v 1.31 2003/03/25 17:24:30 sof Exp $
+ * $Id: RtsUtils.c,v 1.32 2003/03/25 17:58:49 sof Exp $
*
* (c) The GHC Team, 1998-2002
*
return p;
}
+/* To simplify changing the underlying allocator used
+ * by stgMallocBytes(), provide stgFree() as well.
+ */
+void
+stgFree(void* p)
+{
+ free(p);
+}
+
void
_stgAssert (char *filename, unsigned int linenum)
{
/* -----------------------------------------------------------------------------
- * $Id: RtsUtils.h,v 1.14 2003/03/25 17:26:09 sof Exp $
+ * $Id: RtsUtils.h,v 1.15 2003/03/25 17:58:50 sof Exp $
*
* (c) The GHC Team, 1998-1999
*
extern void *stgReallocBytes(void *p, int n, char *msg);
extern void *stgReallocWords(void *p, int n, char *msg);
extern void *stgCallocBytes(int n, int m, char *msg);
+extern void stgFree(void* p);
extern void barf(char *s, ...) __attribute__((__noreturn__)) ;
extern void belch(char *s, ...);
/* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.164 2003/03/25 17:26:09 sof Exp $
+ * $Id: Schedule.c,v 1.165 2003/03/25 17:58:50 sof Exp $
*
* (c) The GHC Team, 1998-2000
*
IF_DEBUG(scheduler, fprintf(stderr, "== scheduler: main thread (%d) finished\n",
m->tso->id));
- free(m);
+ stgFree(m);
// Postcondition: sched_mutex still held
return stat;
/* ---------------------------------------------------------------------------
- * $Id: Sparks.c,v 1.5 2002/01/24 02:06:49 sof Exp $
+ * $Id: Sparks.c,v 1.6 2003/03/25 17:58:50 sof Exp $
*
* (c) The GHC Team, 2000
*
rtsSpark *spark;
{
ASSERT(spark!=NULL);
- free(spark);
+ stgFree(spark);
}
//@cindex disposeSparkQ
}
# endif
- free(spark);
+ stgFree(spark);
}
/*
#include "PosixSource.h"
#include "ThreadLabels.h"
+#include "RtsUtils.h"
#include <stdlib.h>
void * old = NULL;
if ((old = lookupHashTable(threadLabels,key))) {
removeHashTable(threadLabels,key,old);
- free(old);
+ stgFree(old);
}
}