Merge "libcutils: hashmap: save next pointer in forEach before calling callback"

This commit is contained in:
Dima Zavin 2011-04-27 17:06:53 -07:00 committed by Android (Google) Code Review
commit c5ae7dbf4c
1 changed files with 2 additions and 1 deletions

View File

@ -310,10 +310,11 @@ void hashmapForEach(Hashmap* map,
for (i = 0; i < map->bucketCount; i++) {
Entry* entry = map->buckets[i];
while (entry != NULL) {
Entry *next = entry->next;
if (!callback(entry->key, entry->value, context)) {
return;
}
entry = entry->next;
entry = next;
}
}
}