jerenkrantz 2002/12/23 12:41:17
Modified: . CHANGES
include apr_hash.h
tables apr_hash.c
Log:
Allow apr_hash to have greater than int number of elements.
(serf_spider needs a ridiculously large hash table.)
Revision Changes Path
1.365 +3 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.364
retrieving revision 1.365
diff -u -u -r1.364 -r1.365
--- CHANGES 19 Dec 2002 05:19:23 -0000 1.364
+++ CHANGES 23 Dec 2002 20:41:16 -0000 1.365
@@ -1,5 +1,8 @@
Changes with APR 0.9.2
+ *) Allow apr_hash to have greater than int number of elements.
+ [Justin Erenkrantz]
+
*) Allow generation of dependencies by non-GCC compilers.
[Justin Erenkrantz]
1.36 +1 -1 apr/include/apr_hash.h
Index: apr_hash.h
===================================================================
RCS file: /home/cvs/apr/include/apr_hash.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -u -r1.35 -r1.36
--- apr_hash.h 10 Jul 2002 16:45:12 -0000 1.35
+++ apr_hash.h 23 Dec 2002 20:41:16 -0000 1.36
@@ -190,7 +190,7 @@
* @param ht The hash table
* @return The number of key/value pairs in the hash table.
*/
-APR_DECLARE(int) apr_hash_count(apr_hash_t *ht);
+APR_DECLARE(apr_size_t) apr_hash_count(apr_hash_t *ht);
/**
* Merge two hash tables into one new hash table. The values of the overlay
1.32 +11 -10 apr/tables/apr_hash.c
Index: apr_hash.c
===================================================================
RCS file: /home/cvs/apr/tables/apr_hash.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -u -r1.31 -r1.32
--- apr_hash.c 23 Nov 2002 04:29:55 -0000 1.31
+++ apr_hash.c 23 Dec 2002 20:41:17 -0000 1.32
@@ -84,7 +84,7 @@
struct apr_hash_entry_t {
apr_hash_entry_t *next;
- int hash;
+ apr_size_t 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;
- int index;
+ apr_size_t index;
};
/*
@@ -114,7 +114,7 @@
apr_pool_t *pool;
apr_hash_entry_t **array;
apr_hash_index_t iterator; /* For apr_hash_first(NULL, ...) */
- int count, max;
+ apr_size_t 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, int max)
+static apr_hash_entry_t **alloc_array(apr_hash_t *ht, apr_size_t max)
{
return apr_pcalloc(ht->pool, sizeof(*ht->array) * (max + 1));
}
@@ -192,12 +192,13 @@
{
apr_hash_index_t *hi;
apr_hash_entry_t **new_array;
- int new_max;
- int i;
+ apr_size_t 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_size_t i;
+
i = hi->this->hash & new_max;
hi->this->next = new_array[i];
new_array[i] = hi->this;
@@ -222,7 +223,7 @@
{
apr_hash_entry_t **hep, *he;
const unsigned char *p;
- int hash;
+ apr_size_t hash;
apr_ssize_t i;
/*
@@ -303,7 +304,7 @@
{
apr_hash_t *ht;
apr_hash_entry_t *new_vals;
- int i, j;
+ apr_size_t i, j;
ht = apr_palloc(pool, sizeof(apr_hash_t) +
sizeof(*ht->array) * (orig->max + 1) +
@@ -370,7 +371,7 @@
/* else key not present and val==NULL */
}
-APR_DECLARE(int) apr_hash_count(apr_hash_t *ht)
+APR_DECLARE(apr_size_t) apr_hash_count(apr_hash_t *ht)
{
return ht->count;
}
@@ -397,7 +398,7 @@
apr_hash_entry_t *new_vals = NULL;
apr_hash_entry_t *iter;
apr_hash_entry_t *ent;
- int i,j,k;
+ apr_size_t i,j,k;
#ifdef POOL_DEBUG
/* we don't copy keys and values, so it's necessary that