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

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15268
This commit is contained in:
Philippe Waroquiers 2015-05-21 22:01:19 +00:00
parent cd8086c31a
commit d117a8d8b0

View 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);
}