[uClibc]enabling malloc `uClinux broken munmap' code

Erik Andersen andersen at codepoet.org
Thu Oct 17 10:34:53 UTC 2002


On Tue Oct 15, 2002 at 08:55:21AM -0400, Miles Bader wrote:
> Malloc should work with pthreads now; I fixed the locking today (but because
> I don't have a pthreads-capable system, I can't test it).

Close, but needs a few little things.  Feel free to adjust the
heap_mutex_t thing if you prefer to use that.

--- heap.h	9 Oct 2002 10:27:56 -0000	1.10
+++ heap.h	17 Oct 2002 10:29:40 -0000
@@ -38,7 +38,7 @@
   /* 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
 };
--- realloc.c	15 Oct 2002 02:16:58 -0000	1.16
+++ realloc.c	17 Oct 2002 10:29:40 -0000
@@ -51,9 +51,9 @@
     {
       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 @@
   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);
     }
 
 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--



More information about the uClibc mailing list