cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: safe DNS cache pruning

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 27 Apr 2002 14:22:27 +0200 (MET DST)

On Sat, 27 Apr 2002, Daniel Stenberg wrote:

> Just in case someone else feels like joining in and correct our mistakes...

Hah. I got it first! ;-P

I managed to at least find out why this happens and with my fix below, my
test program no longer crashes.

Try this patch, soon to get applied in CVS:

diff -u -r1.9 hash.c
--- hash.c 17 Apr 2002 20:13:55 -0000 1.9
+++ hash.c 27 Apr 2002 12:19:28 -0000
@@ -252,20 +252,24 @@
 /* {{{ 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_hash_clean_with_criterium(curl_hash *h, void *user,
+ int (*comp)(void *, void *))
 {
   curl_llist_element *le;
+ curl_llist_element *lnext;
   int i;

   for (i = 0; i < h->slots; ++i) {
- for (le = CURL_LLIST_HEAD(h->table[i]);
- le != NULL;
- le = CURL_LLIST_NEXT(le)) {
+ le = CURL_LLIST_HEAD(h->table[i]);
+ while(le != NULL)
       if (comp(user, ((curl_hash_element *) CURL_LLIST_VALP(le))->ptr)) {
+ lnext = CURL_LLIST_NEXT(le);
         curl_llist_remove(h->table[i], le, (void *) h);
         --h->size;
+ le = lnext;
       }
- }
+ else
+ le = CURL_LLIST_NEXT(le);
   }
 }

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-04-27