summaryrefslogtreecommitdiff
path: root/tables
diff options
context:
space:
mode:
authorBojan Smojver <bojan@apache.org>2012-01-29 23:38:20 +0000
committerBojan Smojver <bojan@apache.org>2012-01-29 23:38:20 +0000
commit3cde81d1636c1fcea7463c0bf56b9f339d585333 (patch)
tree1e710c211526edf937fd843317cc900e2b204b68 /tables
parenta1c0ca3a1f974c2ac32f1df90da2cd403c8f6320 (diff)
downloadapr-3cde81d1636c1fcea7463c0bf56b9f339d585333.tar.gz
Revert r1237078 partially: do not hash the hash.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1237507 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables')
-rw-r--r--tables/apr_hash.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tables/apr_hash.c b/tables/apr_hash.c
index 93bc424e3..0bf4d28c2 100644
--- a/tables/apr_hash.c
+++ b/tables/apr_hash.c
@@ -106,7 +106,7 @@ APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool)
ht->seed = (unsigned int)((now >> 32) ^ now ^ (apr_uintptr_t)pool ^
(apr_uintptr_t)ht ^ (apr_uintptr_t)&now) - 1;
ht->array = alloc_array(ht, ht->max);
- ht->hash_func = apr_hashfunc_default;
+ ht->hash_func = NULL;
return ht;
}
@@ -289,10 +289,11 @@ static apr_hash_entry_t **find_entry(apr_hash_t *ht,
{
apr_hash_entry_t **hep, *he;
unsigned int hash;
- apr_ssize_t hlen = sizeof(hash);
- hash = ht->hash_func(key, &klen);
- hash = hashfunc_default((char *)&hash, &hlen, ht->seed);
+ if (ht->hash_func)
+ hash = ht->hash_func(key, &klen);
+ else
+ hash = hashfunc_default(key, &klen, ht->seed);
/* scan linked list */
for (hep = &ht->array[hash & ht->max], he = *hep;
@@ -433,7 +434,6 @@ APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p,
apr_hash_entry_t *iter;
apr_hash_entry_t *ent;
unsigned int i, j, k, hash;
- apr_ssize_t hlen = sizeof(hash);
#if APR_POOL_DEBUG
/* we don't copy keys and values, so it's necessary that
@@ -483,8 +483,10 @@ APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p,
for (k = 0; k <= overlay->max; k++) {
for (iter = overlay->array[k]; iter; iter = iter->next) {
- hash = res->hash_func(iter->key, &iter->klen);
- hash = hashfunc_default((char*)&hash, &hlen, res->seed);
+ if (res->hash_func)
+ hash = res->hash_func(iter->key, &iter->klen);
+ else
+ hash = hashfunc_default(iter->key, &iter->klen, res->seed);
i = hash & res->max;
for (ent = res->array[i]; ent; ent = ent->next) {
if ((ent->klen == iter->klen) &&