shithub: MicroHs

Download patch

ref: 20336858f19b2ce0297b5c51adacf097340206ea
parent: 66347eb73994b7094cb5b35e4750aaccffaad62e
author: Rewbert <krookr@chalmers.se>
date: Mon Dec 18 10:09:08 EST 2023

free -> FREE

--- a/src/runtime/config-micro-64.h
+++ b/src/runtime/config-micro-64.h
@@ -67,6 +67,11 @@
  */
 #define MALLOC malloc
 
+/*
+ * Free heap memory, void free(void *p)
+ */
+#define FREE free
+
 #define GCRED    0              /* do some reductions during GC */
 #define FASTTAGS 1              /* compute tag by pointer subtraction */
 #define INTTABLE 1              /* use fixed table of small INT nodes */
--- a/src/runtime/config-mingw-64.h
+++ b/src/runtime/config-mingw-64.h
@@ -51,6 +51,11 @@
  */
 #define MALLOC malloc
 
+/*
+ * Free heap memory, void free(void *p)
+ */
+#define FREE free
+
 #define GCRED    1              /* do some reductions during GC */
 #define FASTTAGS 1              /* compute tag by pointer subtraction */
 #define INTTABLE 1              /* use fixed table of small INT nodes */
--- a/src/runtime/config-unix-64.h
+++ b/src/runtime/config-unix-64.h
@@ -174,6 +174,11 @@
  */
 #define MALLOC malloc
 
+/*
+ * Free heap memory, void free(void *p)
+ */
+#define FREE free
+
 #define GCRED    1              /* do some reductions during GC */
 #define FASTTAGS 1              /* compute tag by pointer subtraction */
 #define INTTABLE 1              /* use fixed table of small INT nodes */
--- a/src/runtime/config-windows-64.h
+++ b/src/runtime/config-windows-64.h
@@ -111,6 +111,11 @@
  */
 #define MALLOC malloc
 
+/*
+ * Free heap memory, void free(void *p)
+ */
+#define FREE free
+
 #define GCRED    1              /* do some reductions during GC */
 #define FASTTAGS 1              /* compute tag by pointer subtraction */
 #define INTTABLE 1              /* use fixed table of small INT nodes */
--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -189,7 +189,7 @@
 node *cells;                 /* All cells */
 
 /*
- * Arrays are allocated with MALLOC()/free().
+ * Arrays are allocated with MALLOC()/FREE().
  * During GC they are marked, and all elements in the array are
  * recursively marked.
  * At the end of the the mark phase there is a scan of all
@@ -329,7 +329,7 @@
 closeb_file(BFILE *bp)
 {
   struct BFILE_file *p = (struct BFILE_file *)bp;
-  free(p);
+  FREE(p);
 }
 
 BFILE *
@@ -464,10 +464,10 @@
 
   for (int i = 0; i < DICTSIZE; i++) {
     if (p->table[i])
-      free(p->table[i]);
+      FREE(p->table[i]);
   }
   p->bfile->closeb(p->bfile);
-  free(p);
+  FREE(p);
 }
 
 BFILE *
@@ -977,7 +977,7 @@
     } else {
       *arrp = arr->next;        /* unlink */
       num_arr_free++;
-      free(arr);                /* and free */
+      FREE(arr);                /* and FREE */
     }
   }
 
@@ -1117,7 +1117,7 @@
 
   //  { "getArgs",   (funptr_t)getArgs,  FFI_A },
   { "getTimeMilli",(funptr_t)GETTIMEMILLI,  FFI_I },
-  { "free",     (funptr_t)free,    FFI_PV },
+  { "free",     (funptr_t)FREE,    FFI_PV },
   { "malloc",   (funptr_t)MALLOC,  FFI_IP }, /* The I is really a size_t */
   { "calloc",   (funptr_t)MALLOC,  FFI_IIP },
   { "peekWord", (funptr_t)peekWord,FFI_PI },
@@ -1404,7 +1404,7 @@
   for(heapoffs_t i = 0; i < shared_table_size; i++)
     shared_table[i].node = NIL;
   NODEPTR n = parse(f);
-  free(shared_table);
+  FREE(shared_table);
   return n;
 }
 
@@ -1674,8 +1674,8 @@
   if (header)
     fprintf(f, "%s%"PRIcounter"\n", VERSION, num_shared);
   printrec(f, n);
-  free(marked_bits);
-  free(shared_bits);
+  FREE(marked_bits);
+  FREE(shared_bits);
 }
 
 /* Show a graph. */
@@ -1956,7 +1956,7 @@
   doing_rnf = (int)noerr;
   rnf_rec(n);
   doing_rnf = 0;
-  free(rnf_bits);
+  FREE(rnf_bits);
 }
 
 NODEPTR execio(NODEPTR n);
@@ -2099,7 +2099,7 @@
 #else
       xd = strtof(msg, NULL);
 #endif
-      free(msg);
+      FREE(msg);
 
       POP(1);
       n = TOP(-1);
@@ -2185,8 +2185,8 @@
       POP(2);
       GCCHECK(strNodes(strlen(res)));
       ARG(TOP(0)) = mkStringC(res);
-      free(res);
-      free(msg);
+      FREE(res);
+      FREE(msg);
       goto err;                 /* XXX not right message if the error is caught */
       }
     case T_NODEFAULT:
@@ -2204,8 +2204,8 @@
 #endif  /* WANT_STDIO */
       GCCHECK(strNodes(strlen(res)));
       ARG(TOP(0)) = mkStringC(res);
-      free(res);
-      free(msg);
+      FREE(res);
+      FREE(msg);
       goto err;                 /* XXX not right message if the error is caught */
       }
     case T_ERROR:
@@ -2268,7 +2268,7 @@
       msg = evalstring(ARG(TOP(0)), 0);
       GCCHECK(1);
       x = ffiNode(msg);
-      free(msg);
+      FREE(msg);
       POP(1);
       n = TOP(-1);
       GOIND(x);
@@ -2458,7 +2458,7 @@
           f = ARG(TOP(2));      /* second argument, handler */
           n = new_ap(f, x);
           cur_handler = h->hdl_old;
-          free(h);
+          FREE(h);
           POP(3);
           goto top;
         } else {
@@ -2465,7 +2465,7 @@
           /* Normal execution: */
           n = execio(ARG(TOP(1))); /* execute first argument */
           cur_handler = h->hdl_old; /* restore old handler */
-          free(h);
+          FREE(h);
           RETIO(n);             /* return result */
         }
       }
--