[PATCH] Fix malloc_usable_size definition

Jason Evans jasone at canonware.com
Tue Oct 9 10:16:07 PDT 2012


On Oct 9, 2012, at 2:21 AM, mh+jemalloc at glandium.org wrote:
> From: Mike Hommey <mh at glandium.org>
> 
> The function declaration in system headers uses void * instead of const void *, and
> that can lead to conflicts when building against recent Android NDKs, where string.h
> includes malloc.h, which contains that conflicting definition.
> ---
> include/jemalloc/jemalloc.h.in |    2 +-
> src/jemalloc.c                 |    2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/jemalloc/jemalloc.h.in b/include/jemalloc/jemalloc.h.in
> index ad06948..f210a0b 100644
> --- a/include/jemalloc/jemalloc.h.in
> +++ b/include/jemalloc/jemalloc.h.in
> @@ -59,7 +59,7 @@ JEMALLOC_EXPORT void *	je_memalign(size_t alignment, size_t size)
> JEMALLOC_EXPORT void *	je_valloc(size_t size) JEMALLOC_ATTR(malloc);
> #endif
> 
> -JEMALLOC_EXPORT size_t	je_malloc_usable_size(const void *ptr);
> +JEMALLOC_EXPORT size_t	je_malloc_usable_size(void *ptr);
> JEMALLOC_EXPORT void	je_malloc_stats_print(void (*write_cb)(void *,
>     const char *), void *je_cbopaque, const char *opts);
> JEMALLOC_EXPORT int	je_mallctl(const char *name, void *oldp,
> diff --git a/src/jemalloc.c b/src/jemalloc.c
> index bc54cd7..9125236 100644
> --- a/src/jemalloc.c
> +++ b/src/jemalloc.c
> @@ -1279,7 +1279,7 @@ JEMALLOC_EXPORT void *(* const __memalign_hook)(size_t alignment, size_t size) =
>  */
> 
> size_t
> -je_malloc_usable_size(const void *ptr)
> +je_malloc_usable_size(void *ptr)
> {
> 	size_t ret;
> 
> -- 
> 1.7.10.4

FreeBSD's malloc_usable_size() uses (const void *ptr) as its argument, so I'd like to get a fix in for this that doesn't require patching jemalloc for FreeBSD.

Thanks,
Jason


More information about the jemalloc-discuss mailing list