summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2005-07-24 15:46:26 +0000
committerThomas Roessler <roessler@does-not-exist.org>2005-07-24 15:46:26 +0000
commit748048778d7d9f76ee0886af3318bef78aa950df (patch)
tree9e3c1cbb78363334ab0b4a41efe145a5d777923e /hash.c
parent961773894640ee288bc33a40d9b03b9de9db018e (diff)
This patch includes (1) a rewrite of hash_delete_hash, and (2) some
changes to the IMAP code that Thomas Glanzmann made during an attempt to squash some segmentation fault in May. There is no guarantee that this patch doesn't break things. If it does, please complain to mutt-dev.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/hash.c b/hash.c
index 01eaad70..a4c72916 100644
--- a/hash.c
+++ b/hash.c
@@ -117,18 +117,22 @@ void hash_delete_hash (HASH * table, int hash, const char *key, const void *data
struct hash_elem *ptr = table->table[hash];
struct hash_elem **last = &table->table[hash];
- for (; ptr; last = &ptr->next, ptr = ptr->next)
+ while (ptr)
{
- /* if `data' is given, look for a matching ->data member. this is
- * required for the case where we have multiple entries with the same
- * key
- */
- if ((data == ptr->data) || (!data && mutt_strcmp (ptr->key, key) == 0))
+ if ((data == ptr->data || !data)
+ && mutt_strcmp (ptr->key, key) == 0)
{
*last = ptr->next;
- if (destroy) destroy (ptr->data);
+ if (destroy)
+ destroy (ptr->data);
FREE (&ptr);
- return;
+
+ ptr = *last;
+ }
+ else
+ {
+ last = &ptr->next;
+ ptr = ptr->next;
}
}
}