diff options
author | Sterling Hughes <sterling@bumblebury.com> | 2002-04-17 20:13:55 +0000 |
---|---|---|
committer | Sterling Hughes <sterling@bumblebury.com> | 2002-04-17 20:13:55 +0000 |
commit | a386562d9a3a351abd567a620a93e4926ce68944 (patch) | |
tree | a22f2cc7bc41e848006b61392ab4e538e89e85dd /lib/hash.c | |
parent | 2bc84fb1639aef24e5c883976dc36c50647a22ff (diff) | |
download | curl-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.c | 20 |
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 |