Commit 2548429c authored by sof's avatar sof
Browse files

[project @ 2003-03-25 17:58:47 by sof]

to ease replacement of the underlying allocator used by stgMallocBytes() and friends, provide (&use) RtsUtils.c:stgFree()
parent e918a7f1
......@@ -520,6 +520,6 @@ freeHaskellFunctionPtr(void* ptr)
#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
......@@ -109,7 +109,7 @@ arenaFree( Arena *arena )
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
......@@ -325,11 +325,11 @@ freeHashTable(HashTable *table, void (*freeDataFun)(void *) )
}
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
*
......@@ -768,13 +768,13 @@ addDLL( char *dll_name )
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" );
......@@ -950,7 +950,7 @@ loadObj( char *path )
# elif defined(OBJFORMAT_MACHO)
oc->formatName = "Mach-O";
# else
free(oc);
stgFree(oc);
barf("loadObj: not implemented on this platform");
# endif
......@@ -1115,14 +1115,14 @@ unloadObj( char *path )
/* 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.
*
......@@ -971,7 +971,7 @@ extern void DEBUG_LoadSymbols( char *name )
}
}
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
......@@ -493,7 +493,7 @@ outputAllRetainerSet(FILE *prof_file)
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
*
......@@ -130,6 +130,15 @@ stgCallocBytes (int n, int m, char *msg)
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
*
......@@ -12,6 +12,7 @@ extern void *stgMallocWords(int n, char *msg);
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
*
......@@ -2359,7 +2359,7 @@ waitThread_(StgMainThread* m
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
*
......@@ -575,7 +575,7 @@ disposeSpark(spark)
rtsSpark *spark;
{
ASSERT(spark!=NULL);
free(spark);
stgFree(spark);
}
//@cindex disposeSparkQ
......@@ -595,7 +595,7 @@ rtsSparkQ spark;
}
# endif
free(spark);
stgFree(spark);
}
/*
......
......@@ -9,6 +9,7 @@
#include "PosixSource.h"
#include "ThreadLabels.h"
#include "RtsUtils.h"
#include <stdlib.h>
......@@ -41,6 +42,6 @@ removeThreadLabel(StgWord key)
void * old = NULL;
if ((old = lookupHashTable(threadLabels,key))) {
removeHashTable(threadLabels,key,old);
free(old);
stgFree(old);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment