]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make MAC_(print_malloc_stats) local by moving it and associated stuff to
authorNicholas Nethercote <njn@valgrind.org>
Sun, 13 Mar 2005 06:10:20 +0000 (06:10 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 13 Mar 2005 06:10:20 +0000 (06:10 +0000)
mac_needs.c.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3336

memcheck/mac_malloc_wrappers.c
memcheck/mac_needs.c
memcheck/mac_shared.h

index 7ee1c0fb931331b49b60ed792c28cda70e1a38fe..63f7eba91d228d03fe9b6a8fcea2afce9dbb48c1 100644 (file)
@@ -526,46 +526,6 @@ void MAC_(mempool_free)(Addr pool, Addr addr)
    die_and_free_mem ( tid, mc, prev_chunk, mp->rzB );
 }
 
-typedef
-   struct {
-      UInt  nblocks;
-      SizeT nbytes;
-   }
-   MallocStats;
-
-static void malloc_stats_count_chunk(VgHashNode* node, void* d) {
-   MAC_Chunk* mc = (MAC_Chunk*)node;
-   MallocStats *ms = (MallocStats *)d;
-
-   ms->nblocks ++;
-   ms->nbytes  += mc->size;
-}
-
-void MAC_(print_malloc_stats) ( void )
-{
-   MallocStats ms;
-  
-   ms.nblocks = 0;
-   ms.nbytes = 0;
-   
-   /* Mmm... more lexical scoping */
-   if (VG_(clo_verbosity) == 0)
-      return;
-
-   /* Count memory still in use. */
-   VG_(HT_apply_to_all_nodes)(MAC_(malloc_list), malloc_stats_count_chunk, &ms);
-
-   VG_(message)(Vg_UserMsg, 
-                "malloc/free: in use at exit: %d bytes in %d blocks.",
-                ms.nbytes, ms.nblocks);
-   VG_(message)(Vg_UserMsg, 
-                "malloc/free: %d allocs, %d frees, %u bytes allocated.",
-                cmalloc_n_mallocs,
-                cmalloc_n_frees, cmalloc_bs_mallocd);
-   if (VG_(clo_verbosity) > 1)
-      VG_(message)(Vg_UserMsg, "");
-}
-
 /*--------------------------------------------------------------------*/
 /*--- end                                    mac_malloc_wrappers.c ---*/
 /*--------------------------------------------------------------------*/
index 28a828e65d3401394fef26a0b96370bc1271fd27..745d03fb9de8e775ebc49e2a9551a795af03a7be 100644 (file)
@@ -828,6 +828,50 @@ static void done_prof_mem ( void ) { }
 
 #endif
 
+/*------------------------------------------------------------*/
+/*--- Statistics printing                                  ---*/
+/*------------------------------------------------------------*/
+
+typedef
+   struct {
+      UInt  nblocks;
+      SizeT nbytes;
+   }
+   MallocStats;
+
+static void malloc_stats_count_chunk(VgHashNode* node, void* d) {
+   MAC_Chunk* mc = (MAC_Chunk*)node;
+   MallocStats *ms = (MallocStats *)d;
+
+   ms->nblocks ++;
+   ms->nbytes  += mc->size;
+}
+
+static void print_malloc_stats ( void )
+{
+   MallocStats ms;
+  
+   ms.nblocks = 0;
+   ms.nbytes = 0;
+   
+   /* Mmm... more lexical scoping */
+   if (VG_(clo_verbosity) == 0)
+      return;
+
+   /* Count memory still in use. */
+   VG_(HT_apply_to_all_nodes)(MAC_(malloc_list), malloc_stats_count_chunk, &ms);
+
+   VG_(message)(Vg_UserMsg, 
+                "malloc/free: in use at exit: %d bytes in %d blocks.",
+                ms.nbytes, ms.nblocks);
+   VG_(message)(Vg_UserMsg, 
+                "malloc/free: %d allocs, %d frees, %u bytes allocated.",
+                cmalloc_n_mallocs,
+                cmalloc_n_frees, cmalloc_bs_mallocd);
+   if (VG_(clo_verbosity) > 1)
+      VG_(message)(Vg_UserMsg, "");
+}
+
 /*------------------------------------------------------------*/
 /*--- Common initialisation + finalisation                 ---*/
 /*------------------------------------------------------------*/
@@ -841,7 +885,7 @@ void MAC_(common_pre_clo_init)(void)
 
 void MAC_(common_fini)(void (*leak_check)(LeakCheckMode mode))
 {
-   MAC_(print_malloc_stats)();
+   print_malloc_stats();
 
    if (VG_(clo_verbosity) == 1) {
       if (MAC_(clo_leak_check) == LC_Off)
index 190fda44be28dae2a148b3844f8c0055df3ce6a7..2f6ad58b7b7c8357a79a1526cf389f1d6c9ed497 100644 (file)
@@ -370,8 +370,6 @@ extern void MAC_(common_fini)         ( void (*leak_check)(LeakCheckMode mode) )
 extern Bool MAC_(handle_common_client_requests) ( ThreadId tid, 
                                                   UWord* arg_block, UWord* ret );
 
-extern void MAC_(print_malloc_stats) ( void );
-
 /* For leak checking */
 extern void MAC_(pp_LeakError)(void* vl, UInt n_this_record, 
                                          UInt n_total_records);