OSDN Git Service

Fix malloc so it compiles and works when using pthreads
authorEric Andersen <andersen@codepoet.org>
Thu, 17 Oct 2002 10:37:43 +0000 (10:37 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 17 Oct 2002 10:37:43 +0000 (10:37 -0000)
 -Erik

libc/stdlib/malloc/heap.h
libc/stdlib/malloc/realloc.c

index 42cde52..ebbc420 100644 (file)
@@ -38,7 +38,7 @@ struct heap
   /* A lock that can be used by callers to control access to the heap.
      The heap code _does not_ use this lock, it's merely here for the
      convenience of users!  */
-  extern heap_mutex_t lock;
+  pthread_mutex_t lock;
 #endif
 };
 
index 32cfacd..9bfe951 100644 (file)
@@ -51,9 +51,9 @@ realloc (void *mem, size_t new_size)
     {
       size_t extra = new_size - size;
 
-      __heap_lock (heap);
+      __heap_lock (&__malloc_heap);
       extra = __heap_alloc_at (&__malloc_heap, base_mem + size, extra);
-      __heap_unlock (heap);
+      __heap_unlock (&__malloc_heap);
 
       if (extra)
        /* Record the changed size.  */
@@ -74,9 +74,9 @@ realloc (void *mem, size_t new_size)
   else if (new_size + MALLOC_REALLOC_MIN_FREE_SIZE <= size)
     /* Shrink the block.  */
     {
-      __heap_lock (heap);
+      __heap_lock (&__malloc_heap);
       __heap_free (&__malloc_heap, base_mem + new_size, size - new_size);
-      __heap_unlock (heap);
+      __heap_unlock (&__malloc_heap);
       MALLOC_SET_SIZE (base_mem, new_size);
     }