summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsof <unknown>2003-03-25 17:58:51 +0000
committersof <unknown>2003-03-25 17:58:51 +0000
commit2548429c5147b40adc0f14a78d24659462358d41 (patch)
tree4e9dd3e2ad3cc073a4bd361a7f5d45b61600af23
parente918a7f155648fc83ed78c8fca85e6e56b77d9ff (diff)
downloadhaskell-2548429c5147b40adc0f14a78d24659462358d41.tar.gz
[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()
-rw-r--r--ghc/rts/Adjustor.c2
-rw-r--r--ghc/rts/Arena.c4
-rw-r--r--ghc/rts/Hash.c6
-rw-r--r--ghc/rts/Linker.c18
-rw-r--r--ghc/rts/Printer.c4
-rw-r--r--ghc/rts/RetainerSet.c4
-rw-r--r--ghc/rts/RtsUtils.c11
-rw-r--r--ghc/rts/RtsUtils.h3
-rw-r--r--ghc/rts/Schedule.c4
-rw-r--r--ghc/rts/Sparks.c6
-rw-r--r--ghc/rts/ThreadLabels.c3
11 files changed, 38 insertions, 27 deletions
diff --git a/ghc/rts/Adjustor.c b/ghc/rts/Adjustor.c
index 18d36735bf..4dca29e177 100644
--- a/ghc/rts/Adjustor.c
+++ b/ghc/rts/Adjustor.c
@@ -520,6 +520,6 @@ freeHaskellFunctionPtr(void* ptr)
#endif
*((unsigned char*)ptr) = '\0';
- free(ptr);
+ stgFree(ptr);
}
diff --git a/ghc/rts/Arena.c b/ghc/rts/Arena.c
index 5043f45fca..ea109accbf 100644
--- a/ghc/rts/Arena.c
+++ b/ghc/rts/Arena.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- $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
diff --git a/ghc/rts/Hash.c b/ghc/rts/Hash.c
index 38cb65a7eb..1083b8a7cc 100644
--- a/ghc/rts/Hash.c
+++ b/ghc/rts/Hash.c
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
- * $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);
}
/* -----------------------------------------------------------------------------
diff --git a/ghc/rts/Linker.c b/ghc/rts/Linker.c
index bccb5f82f4..13cdf3a473 100644
--- a/ghc/rts/Linker.c
+++ b/ghc/rts/Linker.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $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;
}
}
diff --git a/ghc/rts/Printer.c b/ghc/rts/Printer.c
index 0b340df1f2..32abbff1a2 100644
--- a/ghc/rts/Printer.c
+++ b/ghc/rts/Printer.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $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();
}
diff --git a/ghc/rts/RetainerSet.c b/ghc/rts/RetainerSet.c
index af776bf6ce..6834676daf 100644
--- a/ghc/rts/RetainerSet.c
+++ b/ghc/rts/RetainerSet.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $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
diff --git a/ghc/rts/RtsUtils.c b/ghc/rts/RtsUtils.c
index b31b87eb5a..e741ffb07e 100644
--- a/ghc/rts/RtsUtils.c
+++ b/ghc/rts/RtsUtils.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $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)
{
diff --git a/ghc/rts/RtsUtils.h b/ghc/rts/RtsUtils.h
index 5d1dd73796..bada4b6b42 100644
--- a/ghc/rts/RtsUtils.h
+++ b/ghc/rts/RtsUtils.h
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $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, ...);
diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c
index 73bb6209fb..ed6c155de1 100644
--- a/ghc/rts/Schedule.c
+++ b/ghc/rts/Schedule.c
@@ -1,5 +1,5 @@
/* ---------------------------------------------------------------------------
- * $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;
diff --git a/ghc/rts/Sparks.c b/ghc/rts/Sparks.c
index f71af9c2b2..4b447b6292 100644
--- a/ghc/rts/Sparks.c
+++ b/ghc/rts/Sparks.c
@@ -1,5 +1,5 @@
/* ---------------------------------------------------------------------------
- * $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);
}
/*
diff --git a/ghc/rts/ThreadLabels.c b/ghc/rts/ThreadLabels.c
index e7bbd135e3..2856ae7bfd 100644
--- a/ghc/rts/ThreadLabels.c
+++ b/ghc/rts/ThreadLabels.c
@@ -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);
}
}