diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-04-08 12:49:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-04-08 12:49:21 +0000 |
commit | e8757f03baa17eddef096da91122a282a39e9cb7 (patch) | |
tree | 2c62a1129cd4871fb425b239be4e4fb4395de594 /src/util/container_multihashmap.c | |
parent | 66168d493af42bc50cf931f017352cd4b19d69ec (diff) | |
download | gnunet-e8757f03baa17eddef096da91122a282a39e9cb7.tar.gz gnunet-e8757f03baa17eddef096da91122a282a39e9cb7.zip |
make sure key stays valid for iterator even after entry is removed
Diffstat (limited to 'src/util/container_multihashmap.c')
-rw-r--r-- | src/util/container_multihashmap.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c index 7ca6676cb..5b66442cb 100644 --- a/src/util/container_multihashmap.c +++ b/src/util/container_multihashmap.c | |||
@@ -194,6 +194,7 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct | |||
194 | unsigned int i; | 194 | unsigned int i; |
195 | struct MapEntry *e; | 195 | struct MapEntry *e; |
196 | struct MapEntry *n; | 196 | struct MapEntry *n; |
197 | GNUNET_HashCode kc; | ||
197 | 198 | ||
198 | count = 0; | 199 | count = 0; |
199 | for (i = 0; i < map->map_length; i++) | 200 | for (i = 0; i < map->map_length; i++) |
@@ -202,8 +203,12 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct | |||
202 | while (NULL != (e = n)) | 203 | while (NULL != (e = n)) |
203 | { | 204 | { |
204 | n = e->next; | 205 | n = e->next; |
205 | if ((NULL != it) && (GNUNET_OK != it (it_cls, &e->key, e->value))) | 206 | if (NULL != it) |
206 | return GNUNET_SYSERR; | 207 | { |
208 | kc = e->key; | ||
209 | if (GNUNET_OK != it (it_cls, &kc, e->value)) | ||
210 | return GNUNET_SYSERR; | ||
211 | } | ||
207 | count++; | 212 | count++; |
208 | } | 213 | } |
209 | } | 214 | } |
@@ -446,7 +451,7 @@ GNUNET_CONTAINER_multihashmap_get_multiple (const struct | |||
446 | n = e->next; | 451 | n = e->next; |
447 | if (0 != memcmp (key, &e->key, sizeof (GNUNET_HashCode))) | 452 | if (0 != memcmp (key, &e->key, sizeof (GNUNET_HashCode))) |
448 | continue; | 453 | continue; |
449 | if ((it != NULL) && (GNUNET_OK != it (it_cls, &e->key, e->value))) | 454 | if ((it != NULL) && (GNUNET_OK != it (it_cls, key, e->value))) |
450 | return GNUNET_SYSERR; | 455 | return GNUNET_SYSERR; |
451 | count++; | 456 | count++; |
452 | } | 457 | } |