zmalloc fix, return NULL or real malloc failure

This commit is contained in:
antirez 2009-04-30 20:15:18 +02:00
parent 71aee3e959
commit 8d196ebac2
1 changed files with 1 additions and 0 deletions

View File

@ -36,6 +36,7 @@ static size_t used_memory = 0;
void *zmalloc(size_t size) {
void *ptr = malloc(size+sizeof(size_t));
if (!ptr) return NULL;
*((size_t*)ptr) = size;
used_memory += size+sizeof(size_t);
return (char*)ptr+sizeof(size_t);