]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Commit a patch from Olly Betts which avoids a possible problem with
authorNicholas Nethercote <njn@valgrind.org>
Thu, 6 Apr 2006 14:21:42 +0000 (14:21 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Thu, 6 Apr 2006 14:21:42 +0000 (14:21 +0000)
COUNT_LEAKS on 64-bit machines.

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

memcheck/memcheck.h

index 2338fcf2a88ec15b308a25e37b179ce2544ef6b0..0ffc8e1c8044040f4596d6e7c1cf7ccca8b26b78 100644 (file)
@@ -245,13 +245,25 @@ typedef
    }
 
 /* Return number of leaked, dubious, reachable and suppressed bytes found by
-   all previous leak checks.  They must be lvalues. */
+   all previous leak checks.  They must be lvalues.  */
 #define VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed)     \
-   {unsigned int _qzz_res;                                               \
+   /* For safety on 64-bit platforms we assign the results to private
+      unsigned long variables, then assign these to the lvalues the user
+      specified, which works no matter what type 'leaked', 'dubious', etc
+      are.  We also initialise '_qzz_leaked', etc because
+      VG_USERREQ__COUNT_LEAKS doesn't mark the values returned as
+      initialised. */                                                    \
+   {unsigned int  _qzz_res;                                              \
+    unsigned long _qzz_leaked    = 0, _qzz_dubious    = 0;               \
+    unsigned long _qzz_reachable = 0, _qzz_suppressed = 0;               \
     VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                              \
-                            VG_USERREQ__COUNT_LEAKS,                     \
-                            &leaked, &dubious, &reachable, &suppressed,  \
-                            0);                                          \
+                               VG_USERREQ__COUNT_LEAKS,                  \
+                               &_qzz_leaked, &_qzz_dubious,              \
+                               &_qzz_reachable, &_qzz_suppressed, 0);    \
+    leaked     = _qzz_leaked;                                            \
+    dubious    = _qzz_dubious;                                           \
+    reachable  = _qzz_reachable;                                         \
+    suppressed = _qzz_suppressed;                                        \
    }