diff options
Diffstat (limited to 'lib/hash.c')
-rw-r--r-- | lib/hash.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/hash.c b/lib/hash.c index 6ca7431ce..bcd144a11 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -140,8 +140,8 @@ mk_hash_element(const void *key, size_t key_len, const void *p) #define FETCH_LIST(x,y,z) x->table[x->hash_func(y, z, x->slots)] -/* Return the data in the hash. If there already was a match in the hash, - that data is returned. */ +/* Insert the data in the hash. If there already was a match in the hash, + that data is replaced. */ void * Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) { @@ -152,8 +152,9 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) for (le = l->head; le; le = le->next) { he = (struct curl_hash_element *) le->ptr; if(h->comp_func(he->key, he->key_len, key, key_len)) { - h->dtor(p); /* remove the NEW entry */ - return he->ptr; /* return the EXISTING entry */ + Curl_llist_remove(l, le, (void *)h); + --h->size; + break; } } |