wrowe 2003/01/13 10:52:07
Modified: tables apr_hash.c
include apr_hash.h
Log:
A binary-safe patch that satisfies Jerenkrantz's original desire for
more elements, but structured such that we still use the optimal platform
element indexes (a machine int is generally faster than a fractional int).
Revision Changes Path
1.35 +10 -12 apr/tables/apr_hash.c
Index: apr_hash.c
===================================================================
RCS file: /home/cvs/apr/tables/apr_hash.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- apr_hash.c 1 Jan 2003 00:01:55 -0000 1.34
+++ apr_hash.c 13 Jan 2003 18:52:07 -0000 1.35
@@ -84,7 +84,7 @@
struct apr_hash_entry_t {
apr_hash_entry_t *next;
- apr_uint32_t hash;
+ unsigned int hash;
const void *key;
apr_ssize_t klen;
const void *val;
@@ -100,7 +100,7 @@
struct apr_hash_index_t {
apr_hash_t *ht;
apr_hash_entry_t *this, *next;
- apr_uint32_t index;
+ unsigned int index;
};
/*
@@ -114,7 +114,7 @@
apr_pool_t *pool;
apr_hash_entry_t **array;
apr_hash_index_t iterator; /* For apr_hash_first(NULL, ...) */
- apr_uint32_t count, max;
+ unsigned int count, max;
};
#define INITIAL_MAX 15 /* tunable == 2^n - 1 */
@@ -124,7 +124,7 @@
* Hash creation functions.
*/
-static apr_hash_entry_t **alloc_array(apr_hash_t *ht, apr_uint32_t max)
+static apr_hash_entry_t **alloc_array(apr_hash_t *ht, unsigned int max)
{
return apr_pcalloc(ht->pool, sizeof(*ht->array) * (max + 1));
}
@@ -192,14 +192,12 @@
{
apr_hash_index_t *hi;
apr_hash_entry_t **new_array;
- apr_uint32_t new_max;
+ unsigned int new_max;
new_max = ht->max * 2 + 1;
new_array = alloc_array(ht, new_max);
for (hi = apr_hash_first(NULL, ht); hi; hi = apr_hash_next(hi)) {
- apr_uint32_t i;
-
- i = hi->this->hash & new_max;
+ unsigned int i = hi->this->hash & new_max;
hi->this->next = new_array[i];
new_array[i] = hi->this;
}
@@ -223,7 +221,7 @@
{
apr_hash_entry_t **hep, *he;
const unsigned char *p;
- apr_uint32_t hash;
+ unsigned int hash;
apr_ssize_t i;
/*
@@ -304,7 +302,7 @@
{
apr_hash_t *ht;
apr_hash_entry_t *new_vals;
- apr_uint32_t i, j;
+ unsigned int i, j;
ht = apr_palloc(pool, sizeof(apr_hash_t) +
sizeof(*ht->array) * (orig->max + 1) +
@@ -371,7 +369,7 @@
/* else key not present and val==NULL */
}
-APR_DECLARE(apr_uint32_t) apr_hash_count(apr_hash_t *ht)
+APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht)
{
return ht->count;
}
@@ -398,7 +396,7 @@
apr_hash_entry_t *new_vals = NULL;
apr_hash_entry_t *iter;
apr_hash_entry_t *ent;
- apr_uint32_t i,j,k;
+ unsigned int i,j,k;
#ifdef POOL_DEBUG
/* we don't copy keys and values, so it's necessary that
1.39 +1 -1 apr/include/apr_hash.h
Index: apr_hash.h
===================================================================
RCS file: /home/cvs/apr/include/apr_hash.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- apr_hash.h 1 Jan 2003 00:01:45 -0000 1.38
+++ apr_hash.h 13 Jan 2003 18:52:07 -0000 1.39
@@ -190,7 +190,7 @@
* @param ht The hash table
* @return The number of key/value pairs in the hash table.
*/
-APR_DECLARE(apr_uint32_t) apr_hash_count(apr_hash_t *ht);
+APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht);
/**
* Merge two hash tables into one new hash table. The values of the overlay