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 ---*/
/*--------------------------------------------------------------------*/
#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 ---*/
/*------------------------------------------------------------*/
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)
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);