summaryrefslogtreecommitdiff
path: root/malloc/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r--malloc/malloc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index ea10d17f85..b1d43c6447 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, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1996-2009, 2010 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.
@@ -2351,7 +2351,8 @@ typedef struct malloc_chunk* mfastbinptr;
*/
#define set_max_fast(s) \
- global_max_fast = ((s) == 0)? SMALLBIN_WIDTH: request2size(s)
+ global_max_fast = (((s) == 0) \
+ ? SMALLBIN_WIDTH: ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK))
#define get_max_fast() global_max_fast
@@ -3933,9 +3934,10 @@ public_vALLOc(size_t bytes)
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, pagesz, bytes);
- (void)mutex_unlock(&main_arena.mutex);
+ ar_ptr = &main_arena;
+ (void)mutex_lock(&ar_ptr->mutex);
+ p = _int_memalign(ar_ptr, pagesz, bytes);
+ (void)mutex_unlock(&ar_ptr->mutex);
} else {
#if USE_ARENAS
/* ... or sbrk() has failed and there is still a chance to mmap() */
@@ -3978,9 +3980,10 @@ public_pVALLOc(size_t bytes)
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, pagesz, rounded_bytes);
- (void)mutex_unlock(&main_arena.mutex);
+ ar_ptr = &main_arena;
+ (void)mutex_lock(&ar_ptr->mutex);
+ p = _int_memalign(ar_ptr, pagesz, rounded_bytes);
+ (void)mutex_unlock(&ar_ptr->mutex);
} else {
#if USE_ARENAS
/* ... or sbrk() has failed and there is still a chance to mmap() */