static bool
hashmap_delete_node(isc_hashmap_t *hashmap, hashmap_node_t *entry,
- uint32_t hashval, uint32_t psl, const uint8_t idx) {
+ uint32_t hashval, uint32_t psl, const uint8_t idx,
+ size_t size) {
uint32_t pos;
uint32_t hash;
bool last = false;
hashmap->count--;
hash = isc_hash_bits32(hashval, hashmap->tables[idx].hashbits);
- pos = hash + psl;
+ pos = (hash + psl) & hashmap->tables[idx].hashmask;
while (true) {
hashmap_node_t *node = NULL;
break;
}
- if (pos == 0) {
+ if ((pos % size) == 0) {
last = true;
}
node = oldtable[hashmap->hiter];
(void)hashmap_delete_node(hashmap, &oldtable[hashmap->hiter],
- node.hashval, node.psl, oldidx);
+ node.hashval, node.psl, oldidx, UINT32_MAX);
isc_result_t result = hashmap_add(hashmap, node.hashval, NULL, node.key,
node.value, NULL, hashmap->hindex);
node = hashmap_find(hashmap, hashval, match, key, &psl, &idx);
if (node != NULL) {
INSIST(node->key != NULL);
- (void)hashmap_delete_node(hashmap, node, hashval, psl, idx);
+ (void)hashmap_delete_node(hashmap, node, hashval, psl, idx,
+ UINT32_MAX);
result = ISC_R_SUCCESS;
}
&iter->hashmap->tables[iter->hindex].table[iter->i];
if (hashmap_delete_node(iter->hashmap, node, node->hashval, node->psl,
- iter->hindex))
+ iter->hindex, iter->size))
{
/*
* We have seen the new last element so reduce the size