diff options
author | Miles Bader <miles@lsi.nec.co.jp> | 2002-07-25 01:58:57 +0000 |
---|---|---|
committer | Miles Bader <miles@lsi.nec.co.jp> | 2002-07-25 01:58:57 +0000 |
commit | 056f9d98941eb98e453bf4fa308f28b892525baf (patch) | |
tree | 9adaefa6923b1949e06c4a81cf889976a7e8bb18 /libc/stdlib/malloc/realloc.c | |
parent | 255cd531d67d4c5d110409e2a24e2aa5a6249a7a (diff) |
Redo the locking, so that it may actually work. Now locking is done at
the malloc/free level, not within the heap abstraction, and there's a
separate lock to control sbrk access.
Also, get rid of the separate `unmap_free_area' function in free.c, and
just put the code in the `free' function directly, which saves a bunch
of space (even compared to using an inline function) for some reason.
Diffstat (limited to 'libc/stdlib/malloc/realloc.c')
-rw-r--r-- | libc/stdlib/malloc/realloc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index 7d8227aff..7a89712e3 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -39,7 +39,10 @@ realloc (void *mem, size_t new_size) size_t ext_size = new_size - size; void *ext_addr = (char *)base_mem + ext_size; + __malloc_lock (); ext_size = __heap_alloc_at (&__malloc_heap, ext_addr, ext_size); + __malloc_unlock (); + if (! ext_size) /* Our attempts to extend MEM in place failed, just allocate-and-copy. */ |