From 490999ae63bbf1e2cb72a2d14eacb6bd9c4867bc Mon Sep 17 00:00:00 2001 From: rbb Date: Sat, 10 Mar 2001 00:07:09 +0000 Subject: Fix a subtle bug in the hash tables. We can't expand the array after finding the entry because if we do, we immediately overwrite the value. Intead, we have to expand the hash after setting the value. Submitted by: Jon Travis Reviewed by: Ryan Bloom git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61356 13f79535-47bb-0310-9956-ffa450edef68 --- tables/apr_hash.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tables/apr_hash.c') diff --git a/tables/apr_hash.c b/tables/apr_hash.c index 7e7a59ba4..8085ee33f 100644 --- a/tables/apr_hash.c +++ b/tables/apr_hash.c @@ -275,10 +275,7 @@ static apr_hash_entry_t **find_entry(apr_hash_t *ht, he->klen = klen; he->val = val; *hep = he; - /* check that the collision rate isn't too high */ - if (++ht->count > ht->max) { - expand_array(ht); - } + ht->count++; return hep; } @@ -310,6 +307,10 @@ APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, else { /* replace entry */ (*hep)->val = val; + /* check that the collision rate isn't too high */ + if (ht->count > ht->max) { + expand_array(ht); + } } } /* else key not present and val==NULL */ -- cgit v1.2.1