diff options
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 |