bugfix: do not resize hashindex with wrong num_empty

otherwise we would lose the decrement operation on num_empty.
This commit is contained in:
Thomas Waldmann 2023-02-08 15:09:13 +01:00 committed by snsmac
parent ecf5ad43ed
commit 3a44894aca

View file

@ -580,8 +580,7 @@ hashindex_set(HashIndex *index, const unsigned char *key, const void *value)
}
idx = start_idx;
if(BUCKET_IS_EMPTY(index, idx)){
index->num_empty--;
if(index->num_empty < index->min_empty) {
if(index->num_empty <= index->min_empty) {
/* too many tombstones here / not enough empty buckets, do a same-size rebuild */
if(!hashindex_resize(index, index->num_buckets)) {
return 0;
@ -594,6 +593,7 @@ hashindex_set(HashIndex *index, const unsigned char *key, const void *value)
assert(BUCKET_IS_EMPTY(index, start_idx));
idx = start_idx;
}
index->num_empty--;
} else {
/* Bucket must be either EMPTY (see above) or DELETED. */
assert(BUCKET_IS_DELETED(index, idx));