On Mon, 2012-01-30 at 02:22 +1100, Bojan Smojver wrote:
> we could run the hash value produced by hashing the strings through
> the hash function twice

Like this.

-- 
Bojan
Index: tables/apr_hash.c
===================================================================
--- tables/apr_hash.c	(revision 1237208)
+++ tables/apr_hash.c	(working copy)
@@ -288,11 +288,12 @@
                                      const void *val)
 {
     apr_hash_entry_t **hep, *he;
-    unsigned int hash;
-    apr_ssize_t hlen = sizeof(hash);
+    unsigned int hash, temp;
+    apr_ssize_t hlen = sizeof(unsigned int);
 
-    hash = ht->hash_func(key, &klen);
-    hash = hashfunc_default((char *)&hash, &hlen, ht->seed);
+    temp = ht->hash_func(key, &klen);
+    hash = hashfunc_default((char *)&temp, &hlen, ht->seed);
+    hash = hashfunc_default((char *)&temp, &hlen, hash);
 
     /* scan linked list */
     for (hep = &ht->array[hash & ht->max], he = *hep;
@@ -432,8 +433,8 @@
     apr_hash_entry_t *new_vals = NULL;
     apr_hash_entry_t *iter;
     apr_hash_entry_t *ent;
-    unsigned int i, j, k, hash;
-    apr_ssize_t hlen = sizeof(hash);
+    unsigned int i, j, k, hash, temp;
+    apr_ssize_t hlen = sizeof(unsigned int);
 
 #if APR_POOL_DEBUG
     /* we don't copy keys and values, so it's necessary that
@@ -483,8 +484,9 @@
 
     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);
+            temp = res->hash_func(iter->key, &iter->klen);
+            hash = hashfunc_default((char*)&temp, &hlen, res->seed);
+            hash = hashfunc_default((char*)&temp, &hlen, hash);
             i = hash & res->max;
             for (ent = res->array[i]; ent; ent = ent->next) {
                 if ((ent->klen == iter->klen) &&

Reply via email to