From a386562d9a3a351abd567a620a93e4926ce68944 Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Wed, 17 Apr 2002 20:13:55 +0000 Subject: Prune old hostcache entries with each call... This can be optimized a tidbit, but this is a start. --- lib/hash.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/hash.c') diff --git a/lib/hash.c b/lib/hash.c index dd2f00b6a..a262b2a44 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -249,6 +249,26 @@ curl_hash_clean(curl_hash *h) } /* }}} */ +/* {{{ void curl_hash_clean_with_criterium (curl_hash *, void *, int (*)(void *, void *)) + */ +void +curl_hash_clean_with_criterium(curl_hash *h, void *user, int (*comp)(void *, void *)) +{ + curl_llist_element *le; + int i; + + for (i = 0; i < h->slots; ++i) { + for (le = CURL_LLIST_HEAD(h->table[i]); + le != NULL; + le = CURL_LLIST_NEXT(le)) { + if (comp(user, ((curl_hash_element *) CURL_LLIST_VALP(le))->ptr)) { + curl_llist_remove(h->table[i], le, (void *) h); + --h->size; + } + } + } +} + /* {{{ int curl_hash_count (curl_hash *) */ int -- cgit v1.2.3