]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Use a 64-bit counter to keep track of the total number of bytes
authorJulian Seward <jseward@acm.org>
Wed, 14 Mar 2007 11:57:37 +0000 (11:57 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 14 Mar 2007 11:57:37 +0000 (11:57 +0000)
allocated, rather than SizeT which is word-sized.  Your average C++
lardware can easily turn over more than 4G in total in a half hour run
on a 32-bit machine, in which case the counter wraps around.

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

memcheck/mc_malloc_wrappers.c

index be3abe9da8ba91936b53fb369333e2456d60f4ea..9a24a45ec9b0b5164a6bbd982390209d871ae928 100644 (file)
@@ -51,7 +51,7 @@
 /* Stats ... */
 static SizeT cmalloc_n_mallocs  = 0;
 static SizeT cmalloc_n_frees    = 0;
-static SizeT cmalloc_bs_mallocd = 0;
+static ULong cmalloc_bs_mallocd = 0;
 
 /* For debug printing to do with mempools: what stack trace
    depth to show. */
@@ -191,7 +191,7 @@ void* MC_(new_block) ( ThreadId tid,
    }
 
    // Only update this stat if allocation succeeded.
-   cmalloc_bs_mallocd += szB;
+   cmalloc_bs_mallocd += (ULong)szB;
 
    VG_(HT_add_node)( table, create_MC_Chunk(tid, p, szB, kind) );
 
@@ -321,7 +321,7 @@ void* MC_(realloc) ( ThreadId tid, void* p_old, SizeT new_szB )
 
    cmalloc_n_frees ++;
    cmalloc_n_mallocs ++;
-   cmalloc_bs_mallocd += new_szB;
+   cmalloc_bs_mallocd += (ULong)new_szB;
 
    if (complain_about_silly_args(new_szB, "realloc")) 
       return NULL;
@@ -788,7 +788,7 @@ void MC_(print_malloc_stats) ( void )
 {
    MC_Chunk* mc;
    SizeT     nblocks = 0;
-   SizeT     nbytes  = 0;
+   ULong     nbytes  = 0;
    
    if (VG_(clo_verbosity) == 0)
       return;
@@ -799,14 +799,14 @@ void MC_(print_malloc_stats) ( void )
    VG_(HT_ResetIter)(MC_(malloc_list));
    while ( (mc = VG_(HT_Next)(MC_(malloc_list))) ) {
       nblocks++;
-      nbytes += mc->szB;
+      nbytes += (ULong)mc->szB;
    }
 
    VG_(message)(Vg_UserMsg, 
-                "malloc/free: in use at exit: %,lu bytes in %,lu blocks.",
+                "malloc/free: in use at exit: %,llu bytes in %,lu blocks.",
                 nbytes, nblocks);
    VG_(message)(Vg_UserMsg, 
-                "malloc/free: %,lu allocs, %,lu frees, %,lu bytes allocated.",
+                "malloc/free: %,lu allocs, %,lu frees, %,llu bytes allocated.",
                 cmalloc_n_mallocs,
                 cmalloc_n_frees, cmalloc_bs_mallocd);
    if (VG_(clo_verbosity) > 1)