diff options
Diffstat (limited to 'src/zmalloc.h')
-rw-r--r-- | src/zmalloc.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/zmalloc.h b/src/zmalloc.h index 64bc9fc76..d44c7b389 100644 --- a/src/zmalloc.h +++ b/src/zmalloc.h @@ -61,9 +61,19 @@ #define zmalloc_size(p) malloc_size(p) #endif +/* On native libc implementations, we should still do our best to provide a + * HAVE_MALLOC_SIZE capability. This can be set explicitly as well: + * + * NO_MALLOC_USABLE_SIZE disables it on all platforms, even if they are + * known to support it. + * USE_MALLOC_USABLE_SIZE forces use of malloc_usable_size() regardless + * of platform. + */ #ifndef ZMALLOC_LIB #define ZMALLOC_LIB "libc" -#ifdef __GLIBC__ +#if !defined(NO_MALLOC_USABLE_SIZE) && \ + (defined(__GLIBC__) || defined(__FreeBSD__) || \ + defined(USE_MALLOC_USABLE_SIZE)) #include <malloc.h> #define HAVE_MALLOC_SIZE 1 #define zmalloc_size(p) malloc_usable_size(p) |