[project @ 2003-03-25 17:58:47 by sof]
authorsof <unknown>
Tue, 25 Mar 2003 17:58:51 +0000 (17:58 +0000)
committersof <unknown>
Tue, 25 Mar 2003 17:58:51 +0000 (17:58 +0000)
to ease replacement of the underlying allocator used by stgMallocBytes() and friends, provide (&use) RtsUtils.c:stgFree()

ghc/rts/Adjustor.c
ghc/rts/Arena.c
ghc/rts/Hash.c
ghc/rts/Linker.c
ghc/rts/Printer.c
ghc/rts/RetainerSet.c
ghc/rts/RtsUtils.c
ghc/rts/RtsUtils.h
ghc/rts/Schedule.c
ghc/rts/Sparks.c
ghc/rts/ThreadLabels.c

index 18d3673..4dca29e 100644 (file)
@@ -520,6 +520,6 @@ freeHaskellFunctionPtr(void* ptr)
 #endif
  *((unsigned char*)ptr) = '\0';
 
- free(ptr);
+ stgFree(ptr);
 }
 
index 5043f45..ea109ac 100644 (file)
@@ -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
index 38cb65a..1083b8a 100644 (file)
@@ -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);
 }
 
 /* -----------------------------------------------------------------------------
index bccb5f8..13cdf3a 100644 (file)
@@ -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;
        }
     }
index 0b340df..32abbff 100644 (file)
@@ -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();
 }
index af776bf..6834676 100644 (file)
@@ -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
 
index b31b87e..e741ffb 100644 (file)
@@ -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)
 {
index 5d1dd73..bada4b6 100644 (file)
@@ -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, ...);
index 73bb620..ed6c155 100644 (file)
@@ -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;
index f71af9c..4b447b6 100644 (file)
@@ -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);
 }
 
 /*
index e7bbd13..2856ae7 100644 (file)
@@ -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);
   }  
 }