mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
(_int_realloc): Likewise. Third argument is now padded size
This commit is contained in:
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
* malloc/malloc.c (_int_free): Second argument is now mchunkptr.
|
* malloc/malloc.c (_int_free): Second argument is now mchunkptr.
|
||||||
Change all callers.
|
Change all callers.
|
||||||
(_int_realloc): Likewise.
|
(_int_realloc): Likewise. Third argument is now padded size
|
||||||
All _int_* functions are now static.
|
All _int_* functions are now static.
|
||||||
|
|
||||||
* malloc/hooks.c: Change all callers to _int_free and _int_realloc.
|
* malloc/hooks.c: Change all callers to _int_free and _int_realloc.
|
||||||
* malloc/arena.c: Likewise.
|
* malloc/arena.c: Likewise.
|
||||||
* include/malloc.h: Remove now unnecessary declarations of the _int_*
|
* include/malloc.h: Remove now unnecessary declarations of the _int_*
|
||||||
|
@ -354,8 +354,11 @@ realloc_check(oldmem, bytes, caller)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#endif /* HAVE_MMAP */
|
#endif /* HAVE_MMAP */
|
||||||
if (top_check() >= 0)
|
if (top_check() >= 0) {
|
||||||
newmem = _int_realloc(&main_arena, oldp, bytes+1);
|
INTERNAL_SIZE_T nb;
|
||||||
|
checked_request2size(bytes + 1, nb);
|
||||||
|
newmem = _int_realloc(&main_arena, oldp, nb);
|
||||||
|
}
|
||||||
#if 0 /* Erase freed memory. */
|
#if 0 /* Erase freed memory. */
|
||||||
if(newmem)
|
if(newmem)
|
||||||
newp = mem2chunk(newmem);
|
newp = mem2chunk(newmem);
|
||||||
|
@ -1583,7 +1583,7 @@ typedef struct malloc_chunk* mchunkptr;
|
|||||||
|
|
||||||
static Void_t* _int_malloc(mstate, size_t);
|
static Void_t* _int_malloc(mstate, size_t);
|
||||||
static void _int_free(mstate, mchunkptr);
|
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_memalign(mstate, size_t, size_t);
|
||||||
static Void_t* _int_valloc(mstate, size_t);
|
static Void_t* _int_valloc(mstate, size_t);
|
||||||
static Void_t* _int_pvalloc(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);
|
tsd_setspecific(arena_key, (Void_t *)ar_ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
newp = _int_realloc(ar_ptr, oldp, bytes);
|
newp = _int_realloc(ar_ptr, oldp, nb);
|
||||||
|
|
||||||
(void)mutex_unlock(&ar_ptr->mutex);
|
(void)mutex_unlock(&ar_ptr->mutex);
|
||||||
assert(!newp || chunk_is_mmapped(mem2chunk(newp)) ||
|
assert(!newp || chunk_is_mmapped(mem2chunk(newp)) ||
|
||||||
@ -4940,10 +4940,8 @@ static void malloc_consolidate(av) mstate av;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Void_t*
|
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 */
|
mchunkptr newp; /* chunk to return */
|
||||||
INTERNAL_SIZE_T newsize; /* its size */
|
INTERNAL_SIZE_T newsize; /* its size */
|
||||||
Void_t* newmem; /* corresponding user mem */
|
Void_t* newmem; /* corresponding user mem */
|
||||||
@ -4963,12 +4961,6 @@ _int_realloc(mstate av, mchunkptr oldp, size_t bytes)
|
|||||||
|
|
||||||
const char *errstr = NULL;
|
const char *errstr = NULL;
|
||||||
|
|
||||||
|
|
||||||
checked_request2size(bytes, nb);
|
|
||||||
|
|
||||||
/* oldmem size */
|
|
||||||
const INTERNAL_SIZE_T oldsize = chunksize(oldp);
|
|
||||||
|
|
||||||
/* Simple tests for old block integrity. */
|
/* Simple tests for old block integrity. */
|
||||||
if (__builtin_expect (misaligned_chunk (oldp), 0))
|
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));
|
malloc_printerr (check_action, errstr, chunk2mem(oldp));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* oldmem size */
|
||||||
|
const INTERNAL_SIZE_T oldsize = chunksize(oldp);
|
||||||
|
|
||||||
if (__builtin_expect (oldp->size <= 2 * SIZE_SZ, 0)
|
if (__builtin_expect (oldp->size <= 2 * SIZE_SZ, 0)
|
||||||
|| __builtin_expect (oldsize >= av->system_mem, 0))
|
|| __builtin_expect (oldsize >= av->system_mem, 0))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user