dovecot-1.2: hash2_remove_iter(): Never resize hash table, other...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Sep 1 17:41:16 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/10a5483c0d02
changeset: 8151:10a5483c0d02
user: Timo Sirainen <tss at iki.fi>
date: Mon Sep 01 17:41:12 2008 +0300
description:
hash2_remove_iter(): Never resize hash table, otherwise iteration breaks.
diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
src/lib/hash2.c | 14 +++++++++-----
diffs (45 lines):
diff -r 7b5120f7f732 -r 10a5483c0d02 src/lib/hash2.c
--- a/src/lib/hash2.c Mon Sep 01 17:07:37 2008 +0300
+++ b/src/lib/hash2.c Mon Sep 01 17:41:12 2008 +0300
@@ -183,8 +183,9 @@ void *hash2_insert_hash(struct hash2_tab
return value + 1;
}
-static void hash2_remove_value_p(struct hash2_table *hash,
- struct hash2_value **valuep)
+static void
+hash2_remove_value_p(struct hash2_table *hash, struct hash2_value **valuep,
+ bool allow_resize)
{
struct hash2_value *deleted_value;
@@ -195,7 +196,8 @@ static void hash2_remove_value_p(struct
hash->deleted_values = deleted_value;
hash->count--;
- hash2_resize(hash, FALSE);
+ if (allow_resize)
+ hash2_resize(hash, FALSE);
}
void hash2_remove(struct hash2_table *hash, const void *key)
@@ -208,7 +210,7 @@ void hash2_remove(struct hash2_table *ha
while (*valuep != NULL) {
if ((*valuep)->key_hash == key_hash &&
hash->key_compare_cb(key, (*valuep) + 1, hash->context)) {
- hash2_remove_value_p(hash, valuep);
+ hash2_remove_value_p(hash, valuep, TRUE);
return;
}
valuep = &(*valuep)->next;
@@ -225,7 +227,9 @@ void hash2_remove_iter(struct hash2_tabl
while (*valuep != NULL) {
if (*valuep == iter->value) {
next = (*valuep)->next;
- hash2_remove_value_p(hash, valuep);
+ /* don't allow resizing, otherwise iterating would
+ break completely */
+ hash2_remove_value_p(hash, valuep, FALSE);
iter->next_value = next;
return;
}
More information about the dovecot-cvs
mailing list