Browse Source

free(): move stats on top

Ioannis Koutras 13 years ago
parent
commit
450f627af1
1 changed files with 9 additions and 10 deletions
  1. 9 10
      src/custom_free.c

+ 9 - 10
src/custom_free.c

@@ -55,9 +55,16 @@ void custom_ahfree(allocator_t *allocator, heap_t* heap, void *ptr) {
     posix_lock(heap);
     posix_lock(heap);
 #endif /* HAVE_LOCKS */
 #endif /* HAVE_LOCKS */
 
 
-#if defined (WITH_STATS) && defined (REQUEST_SIZE_INFO)
+#ifdef WITH_STATS
+    /* Update Stats */
+#ifdef REQUEST_SIZE_INFO
     heap->dmm_stats.mem_requested -= get_requested_size(ptr);
     heap->dmm_stats.mem_requested -= get_requested_size(ptr);
-#endif /* WITH_STATS && REQUEST_SIZE_INFO */
+#endif /* REQUEST_SIZE_INFO  */
+    heap->dmm_stats.mem_used -= HEADER_SIZE + size;
+    heap->dmm_stats.live_objects -= 1;
+    heap->dmm_stats.num_free += 1;
+    /* End of Stats */
+#endif /* WITH_STATS */
 
 
 #ifdef COUNT_HOPS
 #ifdef COUNT_HOPS
     /* Initialize the hops counter */
     /* Initialize the hops counter */
@@ -217,14 +224,6 @@ void custom_ahfree(allocator_t *allocator, heap_t* heap, void *ptr) {
     }
     }
 #endif /* WITH_FIXED_LISTS */
 #endif /* WITH_FIXED_LISTS */
 
 
-#ifdef WITH_STATS
-    /* Update Stats */
-    heap->dmm_stats.mem_used -= HEADER_SIZE + size;
-    heap->dmm_stats.live_objects -= 1;
-    heap->dmm_stats.num_free += 1;
-    /* End of Stats */
-#endif /* WITH_STATS */
-
 #ifdef WITH_ADAPTIVITY
 #ifdef WITH_ADAPTIVITY
     /* Refresh the state of the heap allocator if a certain number of
     /* Refresh the state of the heap allocator if a certain number of
      * free's has been served already
      * free's has been served already