FYI:
This is actually a one-liner change at the bottom. The log mailer diff'd
against 1.1 rather than 1.1.1.2
*shrug*
-g
On Thu, Jul 13, 2000 at 09:15:07PM -0000, gstein@tigris.org wrote:
> User: gstein
> Date: 00/07/13 14:15:07
>
> Modified: apr/lib apr_hash.c
> Log:
> fix problems with deleting entries from the hash table.
>
> Revision Changes Path
> 1.2 +24 -15 subversion/apr/lib/apr_hash.c
>
> Index: apr_hash.c
> ===================================================================
> RCS file: /cvs/subversion/apr/lib/apr_hash.c,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- apr_hash.c 2000/07/07 23:42:28 1.1
> +++ apr_hash.c 2000/07/13 21:15:07 1.2
> @@ -85,9 +85,9 @@
> struct ap_hash_entry_t {
> ap_hash_entry_t *next;
> int hash;
> - void *key;
> + const void *key;
> size_t klen;
> - void *val;
> + const void *val;
> };
>
> /*
> @@ -167,13 +167,13 @@
> }
>
> APR_EXPORT(void) ap_hash_this(ap_hash_index_t *hi,
> - void **key,
> + const void **key,
> size_t *klen,
> - void **val)
> + void **val)
> {
> if (key) *key = hi->this->key;
> if (klen) *klen = hi->this->klen;
> - if (val) *val = hi->this->val;
> + if (val) *val = (void *)hi->this->val;
> }
>
>
> @@ -206,12 +206,12 @@
> */
>
> static ap_hash_entry_t **find_entry(ap_hash_t *ht,
> - void *key,
> + const void *key,
> size_t klen,
> - void *val)
> + const void *val)
> {
> ap_hash_entry_t **hep, *he;
> - unsigned char *p;
> + const unsigned char *p;
> int hash;
> int i;
>
> @@ -254,25 +254,34 @@
> }
>
> APR_EXPORT(void *) ap_hash_get(ap_hash_t *ht,
> - void *key,
> + const void *key,
> size_t klen)
> {
> ap_hash_entry_t *he;
> he = *find_entry(ht, key, klen, NULL);
> if (he)
> - return he->val;
> + return (void *)he->val;
> else
> return NULL;
> }
>
> APR_EXPORT(void) ap_hash_set(ap_hash_t *ht,
> - void *key,
> + const void *key,
> size_t klen,
> - void *val)
> + const void *val)
> {
> ap_hash_entry_t **hep;
> hep = find_entry(ht, key, klen, val);
> - if (*hep && !val)
> - /* delete entry */
> - *hep = (*hep)->next;
> + if (*hep) {
> + if (!val) {
> + /* delete entry */
> + *hep = (*hep)->next;
> + --ht->count;
> + }
> + else {
> + /* replace entry */
> + (*hep)->val = val;
> + }
> + }
> + /* else key not present and val==NULL */
> }
>
>
>
--
Greg Stein, http://www.lyra.org/
Received on Sat Oct 21 14:36:05 2006