Also compare keys before calling cmp in the hash table stats printing


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15268 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_hashtable.c b/coregrind/m_hashtable.c
index 7b28e0a..bebcaab 100644
--- a/coregrind/m_hashtable.c
+++ b/coregrind/m_hashtable.c
@@ -278,22 +278,18 @@
          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);
          }