From: Philippe Waroquiers Date: Thu, 21 May 2015 22:01:19 +0000 (+0000) Subject: Also compare keys before calling cmp in the hash table stats printing X-Git-Tag: svn/VALGRIND_3_11_0~359 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d117a8d8b0bdc677f065c16e4297b75ca9058f32;p=thirdparty%2Fvalgrind.git Also compare keys before calling cmp in the hash table stats printing git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15268 --- diff --git a/coregrind/m_hashtable.c b/coregrind/m_hashtable.c index 7b28e0a63d..bebcaab616 100644 --- a/coregrind/m_hashtable.c +++ b/coregrind/m_hashtable.c @@ -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); }