From 4a624b8e8b0a14dd03e551b28257d8a54b9ee6f6 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 29 Mar 2007 13:36:07 +0100 Subject: [PATCH] Remove the entry if we return an error code during _cair_hash_table_insert. Previously if we detected an error during resize we would report a failure to insert the entry into the hash table having already done so. --- src/cairo-hash.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cairo-hash.c b/src/cairo-hash.c index 31de81106..b55e7fb39 100644 --- a/src/cairo-hash.c +++ b/src/cairo-hash.c @@ -481,8 +481,12 @@ _cairo_hash_table_insert (cairo_hash_table_t *hash_table, hash_table->live_entries++; status = _cairo_hash_table_resize (hash_table); - if (status) + if (status) { + /* abort the insert... */ + *entry = DEAD_ENTRY; + hash_table->live_entries--; return status; + } return CAIRO_STATUS_SUCCESS; } @@ -561,6 +565,9 @@ _cairo_hash_table_foreach (cairo_hash_table_t *hash_table, * the table may need resizing. Just do this every time * as the check is inexpensive. */ - if (--hash_table->iterating == 0) + if (--hash_table->iterating == 0) { + /* Should we fail to shrink the hash table, it is left unaltered, + * and we don't need to propagate the error status. */ _cairo_hash_table_resize (hash_table); + } }