X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/12d090d2d0a9ff8d2c082b97cf405a30c7126752..b8b8501d70770465adc67d4effb4dbae2899f3a8:/zmalloc.c?ds=sidebyside

diff --git a/zmalloc.c b/zmalloc.c
index b1e96fc3..8658376a 100644
--- a/zmalloc.c
+++ b/zmalloc.c
@@ -40,7 +40,9 @@
 #define PREFIX_SIZE sizeof(size_t)
 #endif
 
-#define increment_used_memory(_n) do { \
+#define increment_used_memory(__n) do { \
+    size_t _n = (__n); \
+    if (_n&(sizeof(long)-1)) _n += sizeof(long)-(_n&(sizeof(long)-1)); \
     if (zmalloc_thread_safe) { \
         pthread_mutex_lock(&used_memory_mutex);  \
         used_memory += _n; \
@@ -50,7 +52,9 @@
     } \
 } while(0)
 
-#define decrement_used_memory(_n) do { \
+#define decrement_used_memory(__n) do { \
+    size_t _n = (__n); \
+    if (_n&(sizeof(long)-1)) _n += sizeof(long)-(_n&(sizeof(long)-1)); \
     if (zmalloc_thread_safe) { \
         pthread_mutex_lock(&used_memory_mutex);  \
         used_memory -= _n; \