]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Also compare keys before calling cmp in the hash table stats printing
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 21 May 2015 22:01:19 +0000 (22:01 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 21 May 2015 22:01:19 +0000 (22:01 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15268

coregrind/m_hashtable.c

index 7b28e0a63daa464121611339c165074f22735c2f..bebcaab6163588b050d002a2544c8f223c94bda8 100644 (file)
@@ -278,22 +278,18 @@ void VG_(HT_print_stats) ( const VgHashTable *table, HT_Cmp_t cmp )
          nelt = 0;
          // Is the same cnode element existing before cnode ?
          for (node = table->chains[i]; node != cnode; node = node->next) {
-            if (cmp) {
-               if ((*cmp)(node, cnode) == 0)
-                  nelt++;
-            } else 
-               if (node->key == cnode->key)
-                  nelt++;
+            if (node->key == cnode->key
+                && (cmp == NULL || cmp (node, cnode) == 0)) {
+               nelt++;
+            }
          }
          // If cnode element not in a previous node, count occurences of elt.
          if (nelt == 0) {
             for (node = cnode; node != NULL; node = node->next) {
-               if (cmp) {
-                  if ((*cmp)(node, cnode) == 0)
-                     nelt++;
-               } else 
-                  if (node->key == cnode->key)
-                     nelt++;
+               if (node->key == cnode->key
+                   && (cmp == NULL || cmp (node, cnode) == 0)) {
+                  nelt++;
+               }
             }
             INCOCCUR(elt_occurences, nelt);
          }