summaryrefslogtreecommitdiff
path: root/lib/hash.c
diff options
context:
space:
mode:
authorSterling Hughes <sterling@bumblebury.com>2002-04-17 20:13:55 +0000
committerSterling Hughes <sterling@bumblebury.com>2002-04-17 20:13:55 +0000
commita386562d9a3a351abd567a620a93e4926ce68944 (patch)
treea22f2cc7bc41e848006b61392ab4e538e89e85dd /lib/hash.c
parent2bc84fb1639aef24e5c883976dc36c50647a22ff (diff)
downloadcurl-a386562d9a3a351abd567a620a93e4926ce68944.tar.gz
Prune old hostcache entries with each call...
This can be optimized a tidbit, but this is a start.
Diffstat (limited to 'lib/hash.c')
-rw-r--r--lib/hash.c20
1 files changed, 20 insertions, 0 deletions
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