Author: njn
Date: 2007-10-04 07:02:41 +0100 (Thu, 04 Oct 2007)
New Revision: 6941

Log:
factor stats taking a little

Modified:
   branches/MASSIF2/massif/ms_main.c


Modified: branches/MASSIF2/massif/ms_main.c
===================================================================
--- branches/MASSIF2/massif/ms_main.c   2007-10-04 05:51:24 UTC (rev 6940)
+++ branches/MASSIF2/massif/ms_main.c   2007-10-04 06:02:41 UTC (rev 6941)
@@ -1230,6 +1230,13 @@
 
 static VgHashTable malloc_list  = NULL;   // HP_Chunks
 
+static void update_alloc_stats(SSizeT szB_delta)
+{
+   // Update total_allocs_deallocs_szB.
+   if (szB_delta < 0) szB_delta = -szB_delta;
+   total_allocs_deallocs_szB += szB_delta;
+}
+
 static void update_heap_stats(SSizeT heap_szB_delta, Int n_heap_blocks_delta)
 {
    if (n_heap_blocks_delta<0) tl_assert(n_heap_blocks >= -n_heap_blocks_delta);
@@ -1237,9 +1244,7 @@
    n_heap_blocks += n_heap_blocks_delta;
    heap_szB      += heap_szB_delta;
 
-   if (heap_szB_delta < 0) total_allocs_deallocs_szB -= heap_szB_delta;
-   if (heap_szB_delta > 0) total_allocs_deallocs_szB += heap_szB_delta;
-   total_allocs_deallocs_szB += clo_heap_admin;
+   update_alloc_stats(heap_szB_delta + clo_heap_admin*n_heap_blocks_delta);
 }
 
 static
@@ -1435,9 +1440,9 @@
 //--- Stacks                                               ---//
 //------------------------------------------------------------//
 
-static void update_stack_stats(SSizeT stack_szB_len)
+static void update_stack_stats(SSizeT stack_szB_delta)
 {
-   total_allocs_deallocs_szB += stack_szB_len;
+   update_alloc_stats(stack_szB_delta);
 }
 
 static void new_mem_stack(Addr a, SizeT len)
@@ -1450,7 +1455,7 @@
 static void die_mem_stack(Addr a, SizeT len)
 {
    n_stack_frees++;
-   update_stack_stats(len);
+   update_stack_stats(-len);
    maybe_take_snapshot("stk-die");
 }
 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to