lib: Fix accounting of memory

* lib/memory.c: (zrealloc) If is called with NULL pointer then it should
  increment allocations because it behaves the same as zmalloc.

  (zfree) is called with NULL pointer, it does nothing therefore allocation
  count should not change.
diff --git a/lib/memory.c b/lib/memory.c
index 4bac31d..4090fd9 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -111,6 +111,9 @@
   memory = realloc (ptr, size);
   if (memory == NULL)
     zerror ("realloc", type, size);
+  if (ptr == NULL)
+    alloc_inc (type);
+
   return memory;
 }
 
@@ -123,8 +126,11 @@
 void
 zfree (int type, void *ptr)
 {
-  alloc_dec (type);
-  free (ptr);
+  if (ptr != NULL)
+    {
+      alloc_dec (type);
+      free (ptr);
+    }
 }
 
 /*