diff options
-rw-r--r-- | lib/memory.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/memory.c b/lib/memory.c index 4bac31db..4090fd90 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -111,6 +111,9 @@ zrealloc (int type, void *ptr, size_t size) memory = realloc (ptr, size); if (memory == NULL) zerror ("realloc", type, size); + if (ptr == NULL) + alloc_inc (type); + return memory; } @@ -123,8 +126,11 @@ zrealloc (int type, void *ptr, size_t size) void zfree (int type, void *ptr) { - alloc_dec (type); - free (ptr); + if (ptr != NULL) + { + alloc_dec (type); + free (ptr); + } } /* |