Remove __malloc_ptr_t.

This commit is contained in:
Joseph Myers 2013-03-08 21:27:42 +00:00
parent 5cc45e102b
commit a222d91a13
6 changed files with 62 additions and 36 deletions

View File

@ -1,5 +1,34 @@
2013-03-08 Joseph Myers <joseph@codesourcery.com>
* malloc/malloc.h (__malloc_ptr_t): Remove macro.
(__free_hook): Use void * instead of __malloc_ptr_t.
(__malloc_hook): Likewise.
(__realloc_hook): Likewise.
(__memalign_hook): Likewise.
(__after_morecore_hook): Likewise.
* malloc/arena.c (save_malloc_hook): Likewise.
(save_free_hook): Likewise.
* malloc/hooks.c (malloc_hook_ini): Likewise.
(realloc_hook_ini): Likewise.
(memalign_hook_ini): Likewise.
* malloc/malloc.c (malloc_hook_ini): Likewise.
(realloc_hook_ini): Likewise.
(memalign_hook_ini): Likewise.
(__free_hook): Likewise.
(__malloc_hook): Likewise.
(__realloc_hook): Likewise.
(__memalign_hook): Likewise.
(__libc_malloc): Likewise.
(__libc_free): Likewise.
(__libc_realloc): Likewise.
(__libc_memalign): Likewise.
(__libc_valloc): Likewise.
(__libc_pvalloc): Likewise.
(__libc_calloc): Likewise.
(__posix_memalign): Likewise.
* malloc/morecore.c (__sbrk): Likewise.
(__default_morecore): Likewise.
* malloc/morecore.c (__default_morecore): Use ISO C prototype.
* malloc/malloc.h (__malloc_ptrdiff_t): Remove macro.

View File

@ -144,11 +144,9 @@ int __malloc_initialized = -1;
/* atfork support. */
static __malloc_ptr_t (*save_malloc_hook) (size_t __size,
const __malloc_ptr_t);
static void (*save_free_hook) (__malloc_ptr_t __ptr,
const __malloc_ptr_t);
static void* save_arena;
static void *(*save_malloc_hook) (size_t __size, const void *);
static void (*save_free_hook) (void *__ptr, const void *);
static void *save_arena;
#ifdef ATFORK_MEM
ATFORK_MEM;

View File

@ -25,7 +25,7 @@
initialization routine, then do the normal work. */
static void*
malloc_hook_ini(size_t sz, const __malloc_ptr_t caller)
malloc_hook_ini(size_t sz, const void *caller)
{
__malloc_hook = NULL;
ptmalloc_init();
@ -33,7 +33,7 @@ malloc_hook_ini(size_t sz, const __malloc_ptr_t caller)
}
static void*
realloc_hook_ini(void* ptr, size_t sz, const __malloc_ptr_t caller)
realloc_hook_ini(void* ptr, size_t sz, const void *caller)
{
__malloc_hook = NULL;
__realloc_hook = NULL;
@ -42,7 +42,7 @@ realloc_hook_ini(void* ptr, size_t sz, const __malloc_ptr_t caller)
}
static void*
memalign_hook_ini(size_t alignment, size_t sz, const __malloc_ptr_t caller)
memalign_hook_ini(size_t alignment, size_t sz, const void *caller)
{
__memalign_hook = NULL;
ptmalloc_init();

View File

@ -1841,22 +1841,22 @@ static void malloc_consolidate(mstate);
/* Forward declarations. */
static void* malloc_hook_ini (size_t sz,
const __malloc_ptr_t caller) __THROW;
const void *caller) __THROW;
static void* realloc_hook_ini (void* ptr, size_t sz,
const __malloc_ptr_t caller) __THROW;
const void *caller) __THROW;
static void* memalign_hook_ini (size_t alignment, size_t sz,
const __malloc_ptr_t caller) __THROW;
const void *caller) __THROW;
void weak_variable (*__malloc_initialize_hook) (void) = NULL;
void weak_variable (*__free_hook) (__malloc_ptr_t __ptr,
const __malloc_ptr_t) = NULL;
__malloc_ptr_t weak_variable (*__malloc_hook)
(size_t __size, const __malloc_ptr_t) = malloc_hook_ini;
__malloc_ptr_t weak_variable (*__realloc_hook)
(__malloc_ptr_t __ptr, size_t __size, const __malloc_ptr_t)
void weak_variable (*__free_hook) (void *__ptr,
const void *) = NULL;
void *weak_variable (*__malloc_hook)
(size_t __size, const void *) = malloc_hook_ini;
void *weak_variable (*__realloc_hook)
(void *__ptr, size_t __size, const void *)
= realloc_hook_ini;
__malloc_ptr_t weak_variable (*__memalign_hook)
(size_t __alignment, size_t __size, const __malloc_ptr_t)
void *weak_variable (*__memalign_hook)
(size_t __alignment, size_t __size, const void *)
= memalign_hook_ini;
void weak_variable (*__after_morecore_hook) (void) = NULL;
@ -2842,7 +2842,7 @@ __libc_malloc(size_t bytes)
mstate ar_ptr;
void *victim;
__malloc_ptr_t (*hook) (size_t, const __malloc_ptr_t)
void *(*hook) (size_t, const void *)
= force_reg (__malloc_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(bytes, RETURN_ADDRESS (0));
@ -2873,7 +2873,7 @@ __libc_free(void* mem)
mstate ar_ptr;
mchunkptr p; /* chunk corresponding to mem */
void (*hook) (__malloc_ptr_t, const __malloc_ptr_t)
void (*hook) (void *, const void *)
= force_reg (__free_hook);
if (__builtin_expect (hook != NULL, 0)) {
(*hook)(mem, RETURN_ADDRESS (0));
@ -2912,7 +2912,7 @@ __libc_realloc(void* oldmem, size_t bytes)
void* newp; /* chunk to return */
__malloc_ptr_t (*hook) (__malloc_ptr_t, size_t, const __malloc_ptr_t) =
void *(*hook) (void *, size_t, const void *) =
force_reg (__realloc_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(oldmem, bytes, RETURN_ADDRESS (0));
@ -3004,7 +3004,7 @@ __libc_memalign(size_t alignment, size_t bytes)
mstate ar_ptr;
void *p;
__malloc_ptr_t (*hook) (size_t, size_t, const __malloc_ptr_t) =
void *(*hook) (size_t, size_t, const void *) =
force_reg (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(alignment, bytes, RETURN_ADDRESS (0));
@ -3046,7 +3046,7 @@ __libc_valloc(size_t bytes)
size_t pagesz = GLRO(dl_pagesize);
__malloc_ptr_t (*hook) (size_t, size_t, const __malloc_ptr_t) =
void *(*hook) (size_t, size_t, const void *) =
force_reg (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(pagesz, bytes, RETURN_ADDRESS (0));
@ -3082,7 +3082,7 @@ __libc_pvalloc(size_t bytes)
size_t page_mask = GLRO(dl_pagesize) - 1;
size_t rounded_bytes = (bytes + page_mask) & ~(page_mask);
__malloc_ptr_t (*hook) (size_t, size_t, const __malloc_ptr_t) =
void *(*hook) (size_t, size_t, const void *) =
force_reg (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(pagesz, rounded_bytes, RETURN_ADDRESS (0));
@ -3125,7 +3125,7 @@ __libc_calloc(size_t n, size_t elem_size)
}
}
__malloc_ptr_t (*hook) (size_t, const __malloc_ptr_t) =
void *(*hook) (size_t, const void *) =
force_reg (__malloc_hook);
if (__builtin_expect (hook != NULL, 0)) {
sz = bytes;
@ -4916,7 +4916,7 @@ __posix_memalign (void **memptr, size_t alignment, size_t size)
/* Call the hook here, so that caller is posix_memalign's caller
and not posix_memalign itself. */
__malloc_ptr_t (*hook) (size_t, size_t, const __malloc_ptr_t) =
void *(*hook) (size_t, size_t, const void *) =
force_reg (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
mem = (*hook)(alignment, size, RETURN_ADDRESS (0));

View File

@ -22,7 +22,6 @@
#include <features.h>
#include <stddef.h>
#include <stdio.h>
# define __malloc_ptr_t void *
#ifdef _LIBC
# define __MALLOC_HOOK_VOLATILE
@ -149,18 +148,18 @@ extern void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void)
__MALLOC_DEPRECATED;
/* Hooks for debugging and user-defined versions. */
extern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr,
const __malloc_ptr_t)
const void *)
__MALLOC_DEPRECATED;
extern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook) (size_t __size,
const __malloc_ptr_t)
const void *)
__MALLOC_DEPRECATED;
extern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook) (void *__ptr,
size_t __size,
const __malloc_ptr_t)
const void *)
__MALLOC_DEPRECATED;
extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook) (size_t __alignment,
size_t __size,
const __malloc_ptr_t)
const void *)
__MALLOC_DEPRECATED;
extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);

View File

@ -30,7 +30,7 @@
#include <stddef.h>
#include <stdlib.h>
extern __malloc_ptr_t __sbrk (ptrdiff_t increment) __THROW;
extern void *__sbrk (ptrdiff_t increment) __THROW;
libc_hidden_proto (__sbrk)
#endif
@ -41,11 +41,11 @@ libc_hidden_proto (__sbrk)
/* Allocate INCREMENT more bytes of data space,
and return the start of data space, or NULL on errors.
If INCREMENT is negative, shrink data space. */
__malloc_ptr_t
void *
__default_morecore (ptrdiff_t increment)
{
__malloc_ptr_t result = (__malloc_ptr_t) __sbrk (increment);
if (result == (__malloc_ptr_t) -1)
void *result = (void *) __sbrk (increment);
if (result == (void *) -1)
return NULL;
return result;
}