Added MemLocks around malloc and free for non-reentrant os-builtin
authorMilind Bhandarkar <milind@cs.uiuc.edu>
Fri, 17 Jan 1997 21:37:45 +0000 (21:37 +0000)
committerMilind Bhandarkar <milind@cs.uiuc.edu>
Fri, 17 Jan 1997 21:37:45 +0000 (21:37 +0000)
memory operations.

src/arch/net/machine.c

index 051926d1c7a0fe2274705f9cde41fc184db033f6..d3e350692f1aab13cefd678fcdbf1dca5a2f560c 100644 (file)
@@ -366,7 +366,13 @@ int size;
   cmi_state cs = CmiState();
   char *res;
   cs->NumAlloc++;
+#if CMK_MALLOC_USE_OS_BUILTIN
+  CmiMemLock();
+#endif
   res =(char *)malloc(size+8);
+#if CMK_MALLOC_USE_OS_BUILTIN
+  CmiMemUnlock();
+#endif
   if (res==0) KillEveryone("Memory allocation failed.");
   ((int *)res)[0]=size;
   return (void *)(res+8);
@@ -383,7 +389,15 @@ void *blk;
 {
   cmi_state cs = CmiState();
   cs->NumFree++;
-  free(((char *)blk)-8);
+#if CMK_MALLOC_USE_OS_BUILTIN
+  CmiMemLock();
+#endif
+  /* Its legal to free a null pointer */
+  if(blk != (void *)0)
+    free(((char *)blk)-8);
+#if CMK_MALLOC_USE_OS_BUILTIN
+  CmiMemUnlock();
+#endif
 }
 
 /*****************************************************************************