summaryrefslogtreecommitdiff
path: root/src/listpack_malloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/listpack_malloc.h')
-rw-r--r--src/listpack_malloc.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/listpack_malloc.h b/src/listpack_malloc.h
index 3a9050052..a8a81c35e 100644
--- a/src/listpack_malloc.h
+++ b/src/listpack_malloc.h
@@ -39,8 +39,11 @@
#ifndef LISTPACK_ALLOC_H
#define LISTPACK_ALLOC_H
#include "zmalloc.h"
-#define lp_malloc zmalloc
-#define lp_realloc zrealloc
+/* We use zmalloc_usable/zrealloc_usable instead of zmalloc/zrealloc
+ * to ensure the safe invocation of 'zmalloc_usable_size().
+ * See comment in zmalloc_usable_size(). */
+#define lp_malloc(sz) zmalloc_usable(sz,NULL)
+#define lp_realloc(ptr,sz) zrealloc_usable(ptr,sz,NULL)
#define lp_free zfree
#define lp_malloc_size zmalloc_usable_size
#endif