Changed behaviour of VALGRIND_COUNT_LEAKS slightly.  Previously, the numbers it
returned (bytes leaked, dubious, etc) were incremented for every leak check
performed.  So if you called VALGRIND_DO_LEAK_CHECK twice in a row, the totals
would be updated twice by the same amount.  This was a bit silly.  So now
COUNT_LEAKS just returns the numbers of bytes leaked found from the previous
leak check.  I even updated the docs, and changed the regression test so old
version fail but the new version passes (by doing two DO_LEAK_CHECKS in a row).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1778 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/mac_needs.c b/memcheck/mac_needs.c
index e90151e..852edb3 100644
--- a/memcheck/mac_needs.c
+++ b/memcheck/mac_needs.c
@@ -801,10 +801,12 @@
    switch (arg[0]) {
    case VG_USERREQ__COUNT_LEAKS: { /* count leaked bytes */
       UInt** argp = (UInt**)arg;
-      *argp[1] = MAC_(total_bytes_leaked);
-      *argp[2] = MAC_(total_bytes_dubious);
-      *argp[3] = MAC_(total_bytes_reachable);
-      *argp[4] = MAC_(total_bytes_suppressed);
+      // MAC_(bytes_leaked) et al were set by the last leak check (or zero
+      // if no prior leak checks performed).
+      *argp[1] = MAC_(bytes_leaked);
+      *argp[2] = MAC_(bytes_dubious);
+      *argp[3] = MAC_(bytes_reachable);
+      *argp[4] = MAC_(bytes_suppressed);
       *ret = 0;
       return True;
    }