summaryrefslogtreecommitdiff
path: root/malloc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-01-11 07:45:15 +0000
committerJakub Jelinek <jakub@redhat.com>2008-01-11 07:45:15 +0000
commit07b7d301cc62d3f4ff1bbaf668ddc2510f7a55d8 (patch)
treeb7a82272de69e03b1850cb2cf93e25f258769fa2 /malloc
parent1e44f485d223b0f2f7b194935a0109cb7b713cc3 (diff)
Updated to fedora-glibc-20080111T0737
Diffstat (limited to 'malloc')
-rw-r--r--malloc/malloc.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index fc8a83c328..e00eb0f4e2 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1,5 +1,5 @@
/* Malloc implementation for multiple threads without lock contention.
- Copyright (C) 1996-2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1996-2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Wolfram Gloger <wg@malloc.de>
and Doug Lea <dl@cs.oswego.edu>, 2001.
@@ -3553,9 +3553,10 @@ public_mALLOc(size_t bytes)
/* Maybe the failure is due to running out of mmapped areas. */
if(ar_ptr != &main_arena) {
(void)mutex_unlock(&ar_ptr->mutex);
- (void)mutex_lock(&main_arena.mutex);
- victim = _int_malloc(&main_arena, bytes);
- (void)mutex_unlock(&main_arena.mutex);
+ ar_ptr = &main_arena;
+ (void)mutex_lock(&ar_ptr->mutex);
+ victim = _int_malloc(ar_ptr, bytes);
+ (void)mutex_unlock(&ar_ptr->mutex);
} else {
#if USE_ARENAS
/* ... or sbrk() has failed and there is still a chance to mmap() */
@@ -3760,24 +3761,28 @@ public_mEMALIGn(size_t alignment, size_t bytes)
if(!ar_ptr)
return 0;
p = _int_memalign(ar_ptr, alignment, bytes);
- (void)mutex_unlock(&ar_ptr->mutex);
if(!p) {
/* Maybe the failure is due to running out of mmapped areas. */
if(ar_ptr != &main_arena) {
- (void)mutex_lock(&main_arena.mutex);
- p = _int_memalign(&main_arena, alignment, bytes);
- (void)mutex_unlock(&main_arena.mutex);
+ (void)mutex_unlock(&ar_ptr->mutex);
+ ar_ptr = &main_arena;
+ (void)mutex_lock(&ar_ptr->mutex);
+ p = _int_memalign(ar_ptr, alignment, bytes);
+ (void)mutex_unlock(&ar_ptr->mutex);
} else {
#if USE_ARENAS
/* ... or sbrk() has failed and there is still a chance to mmap() */
- ar_ptr = arena_get2(ar_ptr->next ? ar_ptr : 0, bytes);
+ mstate prev = ar_ptr->next ? ar_ptr : 0;
+ (void)mutex_unlock(&ar_ptr->mutex);
+ ar_ptr = arena_get2(prev, bytes);
if(ar_ptr) {
p = _int_memalign(ar_ptr, alignment, bytes);
(void)mutex_unlock(&ar_ptr->mutex);
}
#endif
}
- }
+ } else
+ (void)mutex_unlock(&ar_ptr->mutex);
assert(!p || chunk_is_mmapped(mem2chunk(p)) ||
ar_ptr == arena_for_chunk(mem2chunk(p)));
return p;