fyi...
I'm gonna go through and check our usage. Make sure we're passing the right
values.
Cheers,
-g
----- Forwarded message from gstein@locus.apache.org -----
Reply-To: new-httpd@apache.org
Date: 16 Oct 2000 02:58:17 -0000
From: gstein@locus.apache.org
To: apache-2.0-cvs@apache.org
Subject: cvs commit: apache-2.0/src/modules/dav/main liveprop.c providers.c
gstein 00/10/15 19:58:16
Modified: src/lib/apr/include apr_hash.h
src/lib/apr/tables apr_hash.c
src/modules/dav/main liveprop.c providers.c
Log:
the zero-length hash key is valid. use (-1) as the discrimnator for
auto-computed string-length hash keys
Revision Changes Path
1.12 +14 -6 apache-2.0/src/lib/apr/include/apr_hash.h
Index: apr_hash.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_hash.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- apr_hash.h 2000/10/11 17:13:12 1.11
+++ apr_hash.h 2000/10/16 02:58:13 1.12
@@ -70,6 +70,16 @@
#include "apr_pools.h"
/*
+ * When passing a key to apr_hash_set or apr_hash_get, this value can be
+ * passed to indicate a string-valued key, and have apr_hash compute the
+ * length automatically.
+ *
+ * Note: apr_hash will use strlen(key)+1 for the length. This allows
+ * apr_hash_this() to return a null-terminated string as the key.
+ */
+#define APR_HASH_KEY_STRING (-1)
+
+/*
* Abstract type for hash tables.
*/
typedef struct apr_hash_t apr_hash_t;
@@ -91,26 +101,24 @@
* Associate a value with a key in a hash table.
* @param ht The hash table
* @param key Pointer to the key
- * @param klen Length of the key
- * If the length is 0 it is assumed to be strlen(key)+1
+ * @param klen Length of the key. Can be APR_HASH_KEY_STRING.
* @param val Value to associate with the key
* @tip If the value is NULL the hash entry is deleted.
* @deffunc void apr_hash_set(apr_hash_t *ht, const void *key, apr_size_t klen, const void *val)
*/
APR_EXPORT(void) apr_hash_set(apr_hash_t *ht, const void *key,
- apr_size_t klen, const void *val);
+ apr_ssize_t klen, const void *val);
/**
* Look up the value associated with a key in a hash table.
* @param ht The hash table
* @param key Pointer to the key
- * @param klen Length of the key
- * If the length is 0 it is assumed to be strlen(key)+1
+ * @param klen Length of the key. Can be APR_HASH_KEY_STRING.
* @return Returns NULL if the key is not present.
* @deffunc void *apr_hash_get(apr_hash_t *ht, const void *key, apr_size_t klen)
*/
APR_EXPORT(void*) apr_hash_get(apr_hash_t *ht, const void *key,
- apr_size_t klen);
+ apr_ssize_t klen);
/**
* Start iterating over the entries in a hash table.
1.5 +4 -4 apache-2.0/src/lib/apr/tables/apr_hash.c
Index: apr_hash.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/tables/apr_hash.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- apr_hash.c 2000/10/05 22:20:37 1.4
+++ apr_hash.c 2000/10/16 02:58:14 1.5
@@ -207,7 +207,7 @@
static apr_hash_entry_t **find_entry(apr_hash_t *ht,
const void *key,
- apr_size_t klen,
+ apr_ssize_t klen,
const void *val)
{
apr_hash_entry_t **hep, *he;
@@ -215,7 +215,7 @@
int hash;
int i;
- if (klen == 0)
+ if (klen == APR_HASH_KEY_STRING)
klen = strlen(key) + 1;
/*
@@ -282,7 +282,7 @@
APR_EXPORT(void *) apr_hash_get(apr_hash_t *ht,
const void *key,
- apr_size_t klen)
+ apr_ssize_t klen)
{
apr_hash_entry_t *he;
he = *find_entry(ht, key, klen, NULL);
@@ -294,7 +294,7 @@
APR_EXPORT(void) apr_hash_set(apr_hash_t *ht,
const void *key,
- apr_size_t klen,
+ apr_ssize_t klen,
const void *val)
{
apr_hash_entry_t **hep;
1.5 +4 -3 apache-2.0/src/modules/dav/main/liveprop.c
Index: liveprop.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/dav/main/liveprop.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- liveprop.c 2000/10/11 17:23:53 1.4
+++ liveprop.c 2000/10/16 02:58:15 1.5
@@ -87,19 +87,20 @@
apr_register_cleanup(p, NULL, dav_cleanup_liveprops, apr_null_cleanup);
}
- value = (int)apr_hash_get(dav_liveprop_uris, uri, 0);
+ value = (int)apr_hash_get(dav_liveprop_uris, uri, APR_HASH_KEY_STRING);
if (value != 0) {
/* already registered */
return;
}
/* start at 1, and count up */
- apr_hash_set(dav_liveprop_uris, uri, 0, (void *)++dav_liveprop_count);
+ apr_hash_set(dav_liveprop_uris, uri, APR_HASH_KEY_STRING,
+ (void *)++dav_liveprop_count);
}
DAV_DECLARE(int) dav_get_liveprop_ns_index(const char *uri)
{
- return (int)apr_hash_get(dav_liveprop_uris, uri, 0);
+ return (int)apr_hash_get(dav_liveprop_uris, uri, APR_HASH_KEY_STRING);
}
int dav_get_liveprop_ns_count(void)
1.4 +3 -3 apache-2.0/src/modules/dav/main/providers.c
Index: providers.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/dav/main/providers.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- providers.c 2000/10/11 17:23:54 1.3
+++ providers.c 2000/10/16 02:58:15 1.4
@@ -70,7 +70,7 @@
}
DAV_DECLARE(void) dav_register_provider(apr_pool_t *p, const char *name,
- const dav_provider *provider)
+ const dav_provider *provider)
{
/* ### ignore the pool; it is NULL right now */
p = ap_global_hook_pool;
@@ -81,10 +81,10 @@
}
/* just set it. no biggy if it was there before. */
- apr_hash_set(dav_repos_providers, name, 0, provider);
+ apr_hash_set(dav_repos_providers, name, APR_HASH_KEY_STRING, provider);
}
const dav_provider * dav_lookup_provider(const char *name)
{
- return apr_hash_get(dav_repos_providers, name, 0);
+ return apr_hash_get(dav_repos_providers, name, APR_HASH_KEY_STRING);
}
----- End forwarded message -----
--
Greg Stein, http://www.lyra.org/
Received on Sat Oct 21 14:36:11 2006