Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Unified Diff: runtime/platform/hashmap.h

Issue 2533303005: VM: Fix memory leak during shutdown (Closed)
Patch Set: Simplify socket.cc by not updating hashmaps during shutdown Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/platform/hashmap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/hashmap.h
diff --git a/runtime/platform/hashmap.h b/runtime/platform/hashmap.h
index 1fd1235153dda9e5e3b02ad6685dd311a689cc92..240e94d1a0f523a4c7eb17f2537507295bf588c5 100644
--- a/runtime/platform/hashmap.h
+++ b/runtime/platform/hashmap.h
@@ -61,8 +61,28 @@ class HashMap {
Entry* Lookup(void* key, uint32_t hash, bool insert);
// Removes the entry with matching key.
+ //
+ // WARNING: This method cannot be called while iterating a `HashMap`
+ // otherwise the iteration might step over elements!
void Remove(void* key, uint32_t hash);
+ // Removes the entry and returns the next entry (in iteration order) after
+ // this one.
+ //
+ // Usage instructions for removing elements during iteration:
+ //
+ // HashMap::Entry* current = map.Start();
+ // while (current != NULL) {
+ // ...
+ // if (condition) {
+ // current = map.Remove(current);
+ // } else {
+ // current = map.Next(current);
+ // }
+ // }
+ //
+ Entry* Remove(Entry* entry);
+
// Empties the hash map (occupancy() == 0), and calls the function 'clear' on
// each of the values if given.
void Clear(ClearFun clear = NULL);
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/platform/hashmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698