X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/e2641e09cc0daf44f63f654230f72d22acf3a9af..b301c1fc2bbf977a7d9fd4718cd9914113541c75:/src/zmalloc.c diff --git a/src/zmalloc.c b/src/zmalloc.c index 8658376a..5c1b5e9a 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -89,6 +89,20 @@ void *zmalloc(size_t size) { #endif } +void *zcalloc(size_t size) { + void *ptr = calloc(1, size+PREFIX_SIZE); + + if (!ptr) zmalloc_oom(size); +#ifdef HAVE_MALLOC_SIZE + increment_used_memory(redis_malloc_size(ptr)); + return ptr; +#else + *((size_t*)ptr) = size; + increment_used_memory(size+PREFIX_SIZE); + return (char*)ptr+PREFIX_SIZE; +#endif +} + void *zrealloc(void *ptr, size_t size) { #ifndef HAVE_MALLOC_SIZE void *realptr;