aboutsummaryrefslogtreecommitdiff
path: root/malloc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-02-07 22:49:34 +0000
committerUlrich Drepper <drepper@redhat.com>2009-02-07 22:49:34 +0000
commit6dd6a580dff2b88b3bf6a37f59068bbfeb51c97d (patch)
treef3609b33f834af55001e84f6aee52b9eb7941395 /malloc
parent78ac92ad8d6c97c57d09bef01608622706b24f65 (diff)
downloadglibc-6dd6a580dff2b88b3bf6a37f59068bbfeb51c97d.tar
glibc-6dd6a580dff2b88b3bf6a37f59068bbfeb51c97d.tar.gz
glibc-6dd6a580dff2b88b3bf6a37f59068bbfeb51c97d.tar.bz2
glibc-6dd6a580dff2b88b3bf6a37f59068bbfeb51c97d.zip
(_int_realloc): Likewise. Third argument is now padded size
Diffstat (limited to 'malloc')
-rw-r--r--malloc/hooks.c7
-rw-r--r--malloc/malloc.c18
2 files changed, 12 insertions, 13 deletions
diff --git a/malloc/hooks.c b/malloc/hooks.c
index 537995aeab..9659ec5fbe 100644
--- a/malloc/hooks.c
+++ b/malloc/hooks.c
@@ -354,8 +354,11 @@ realloc_check(oldmem, bytes, caller)
}
} else {
#endif /* HAVE_MMAP */
- if (top_check() >= 0)
- newmem = _int_realloc(&main_arena, oldp, bytes+1);
+ if (top_check() >= 0) {
+ INTERNAL_SIZE_T nb;
+ checked_request2size(bytes + 1, nb);
+ newmem = _int_realloc(&main_arena, oldp, nb);
+ }
#if 0 /* Erase freed memory. */
if(newmem)
newp = mem2chunk(newmem);
diff --git a/malloc/malloc.c b/malloc/malloc.c
index a4695b71fc..12e23b0f9b 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1583,7 +1583,7 @@ typedef struct malloc_chunk* mchunkptr;
static Void_t* _int_malloc(mstate, size_t);
static void _int_free(mstate, mchunkptr);
-static Void_t* _int_realloc(mstate, mchunkptr, size_t);
+static Void_t* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T);
static Void_t* _int_memalign(mstate, size_t, size_t);
static Void_t* _int_valloc(mstate, size_t);
static Void_t* _int_pvalloc(mstate, size_t);
@@ -3704,7 +3704,7 @@ public_rEALLOc(Void_t* oldmem, size_t bytes)
tsd_setspecific(arena_key, (Void_t *)ar_ptr);
#endif
- newp = _int_realloc(ar_ptr, oldp, bytes);
+ newp = _int_realloc(ar_ptr, oldp, nb);
(void)mutex_unlock(&ar_ptr->mutex);
assert(!newp || chunk_is_mmapped(mem2chunk(newp)) ||
@@ -4940,10 +4940,8 @@ static void malloc_consolidate(av) mstate av;
*/
Void_t*
-_int_realloc(mstate av, mchunkptr oldp, size_t bytes)
+_int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T nb)
{
- INTERNAL_SIZE_T nb; /* padded request size */
-
mchunkptr newp; /* chunk to return */
INTERNAL_SIZE_T newsize; /* its size */
Void_t* newmem; /* corresponding user mem */
@@ -4963,12 +4961,6 @@ _int_realloc(mstate av, mchunkptr oldp, size_t bytes)
const char *errstr = NULL;
-
- checked_request2size(bytes, nb);
-
- /* oldmem size */
- const INTERNAL_SIZE_T oldsize = chunksize(oldp);
-
/* Simple tests for old block integrity. */
if (__builtin_expect (misaligned_chunk (oldp), 0))
{
@@ -4977,6 +4969,10 @@ _int_realloc(mstate av, mchunkptr oldp, size_t bytes)
malloc_printerr (check_action, errstr, chunk2mem(oldp));
return NULL;
}
+
+ /* oldmem size */
+ const INTERNAL_SIZE_T oldsize = chunksize(oldp);
+
if (__builtin_expect (oldp->size <= 2 * SIZE_SZ, 0)
|| __builtin_expect (oldsize >= av->system_mem, 0))
{