From 173d692bc2e87d476a8ef45b671cf9ac98695c15 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 10 Jan 2017 11:25:39 +0100 Subject: Defrag: activate it only if running modified version of Jemalloc. This commit also includes minor aesthetic changes like removal of trailing spaces. --- src/zmalloc.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/zmalloc.h') diff --git a/src/zmalloc.h b/src/zmalloc.h index 2f7015490..b6d4e1d97 100644 --- a/src/zmalloc.h +++ b/src/zmalloc.h @@ -65,12 +65,17 @@ #define ZMALLOC_LIB "libc" #endif +/* We can enable the Redis defrag capabilities only if we are using Jemalloc + * and the version used is our special version modified for Redis having + * the ability to return per-allocation fragmentation hints. */ +#if defined(USE_JEMALLOC) && defined(JEMALLOC_FRAG_HINT) +#define HAVE_DEFRAG +#endif + void *zmalloc(size_t size); void *zcalloc(size_t size); void *zrealloc(void *ptr, size_t size); void zfree(void *ptr); -void zfree_no_tcache(void *ptr); -void *zmalloc_no_tcache(size_t size); char *zstrdup(const char *s); size_t zmalloc_used_memory(void); void zmalloc_enable_thread_safeness(void); @@ -82,6 +87,11 @@ size_t zmalloc_get_smap_bytes_by_field(char *field, long pid); size_t zmalloc_get_memory_size(void); void zlibc_free(void *ptr); +#ifdef HAVE_DEFRAG +void zfree_no_tcache(void *ptr); +void *zmalloc_no_tcache(size_t size); +#endif + #ifndef HAVE_MALLOC_SIZE size_t zmalloc_size(void *ptr); #endif -- cgit v1.2.1