[MLton-commit] r6244

Matthew Fluet fluet at mlton.org
Sun Dec 9 10:23:24 PST 2007


Archival commit.

Older versions of GMP don't provide 'mp_get_memory_functions'.
Default to using 'malloc', 'realloc', and 'free'.


----------------------------------------------------------------------

U   mlton/trunk/runtime/gc/int-inf.c

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/gc/int-inf.c
===================================================================
--- mlton/trunk/runtime/gc/int-inf.c	2007-12-09 18:20:20 UTC (rev 6243)
+++ mlton/trunk/runtime/gc/int-inf.c	2007-12-09 18:23:24 UTC (rev 6244)
@@ -368,15 +368,11 @@
 
 static GC_state intInfMemoryFuncsState;
 
-static void *(*alloc_func_ptr)(size_t) = NULL;
-static void *(*realloc_func_ptr)(void *, size_t, size_t) = NULL;
-static void (*free_func_ptr)(void *, size_t) = NULL;
-
 static void * wrap_alloc_func(size_t size) {
   if (DEBUG_INT_INF)
     fprintf (stderr, "alloc_func (size = %"PRIuMAX") = ", 
              (uintmax_t)size);
-  void * res = (*alloc_func_ptr)(size);
+  void * res = malloc(size);
   if (DEBUG_INT_INF)
     fprintf (stderr, FMTPTR"\n", (uintptr_t)res);
   return res;
@@ -388,7 +384,7 @@
              "old_size = %"PRIuMAX", new_size = %"PRIuMAX") = ", 
              (uintptr_t)ptr, (uintmax_t)old_size, (uintmax_t)new_size);
   assert (! isPointerInHeap(intInfMemoryFuncsState, (pointer)ptr));
-  void * res = (*realloc_func_ptr)(ptr, old_size, new_size);
+  void * res = realloc(ptr, new_size);
   if (DEBUG_INT_INF)
     fprintf (stderr, FMTPTR"\n", (uintptr_t)res);
   return res;
@@ -399,7 +395,7 @@
     fprintf (stderr, "free_func (ptr = "FMTPTR", size = %"PRIuMAX")", 
              (uintptr_t)ptr, (uintmax_t)size);
   assert (! isPointerInHeap(intInfMemoryFuncsState, (pointer)ptr));
-  (*free_func_ptr)(ptr, size);
+  free(ptr);
   if (DEBUG_INT_INF)
     fprintf (stderr, "\n");
   return;
@@ -407,7 +403,6 @@
 
 void initIntInf (GC_state s) {
   intInfMemoryFuncsState = s;
-  mp_get_memory_functions (&alloc_func_ptr, &realloc_func_ptr, &free_func_ptr);
   mp_set_memory_functions (&wrap_alloc_func, &wrap_realloc_func, &wrap_free_func);
   return;
 }




More information about the MLton-commit mailing list