support removing of current entry by callback
authorChristian Grothoff <christian@grothoff.org>
Fri, 29 Jan 2010 12:21:03 +0000 (12:21 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 29 Jan 2010 12:21:03 +0000 (12:21 +0000)
src/util/container_multihashmap.c

index e291b8b50dc3235080efd440edc7cf434b9a785e..773b24928b06367f74e5996060cab9c3aa3ff85d 100644 (file)
@@ -435,18 +435,18 @@ GNUNET_CONTAINER_multihashmap_get_multiple (const struct
 {
   int count;
   struct MapEntry *e;
+  struct MapEntry *n;
 
   count = 0;
-  e = map->map[idx_of (map, key)];
-  while (e != NULL)
+  n = map->map[idx_of (map, key)];
+  while (NULL != (e = n))
     {
-      if (0 == memcmp (key, &e->key, sizeof (GNUNET_HashCode)))
-        {
-          if ((it != NULL) && (GNUNET_OK != it (it_cls, &e->key, e->value)))
-            return GNUNET_SYSERR;
-          count++;
-        }
-      e = e->next;
+      n = e->next;
+      if (0 != memcmp (key, &e->key, sizeof (GNUNET_HashCode)))
+       continue;
+      if ((it != NULL) && (GNUNET_OK != it (it_cls, &e->key, e->value)))
+       return GNUNET_SYSERR;
+      count++;
     }
   return count;
 }