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

Unified Diff: runtime/platform/hashmap.h

Issue 2228503007: Fixes memory leaks in the eventhandler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 4 months 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 d5a02930f45f4c780c89229ba293f48aba1c231b..b5c938f4c42077414f5bc9d519fed1179a99f603 100644
--- a/runtime/platform/hashmap.h
+++ b/runtime/platform/hashmap.h
@@ -13,6 +13,8 @@ class HashMap {
public:
typedef bool (*MatchFun) (void* key1, void* key2);
+ typedef void (*ClearFun) (void* value);
+
static bool SamePointerValue(void* key1, void* key2) {
return key1 == key2;
}
@@ -48,6 +50,7 @@ class HashMap {
// Some clients may not need to use the value slot
// (e.g. implementers of sets, where the key is the value).
struct Entry {
+ Entry() : key(NULL), value(NULL), hash(0) {}
void* key;
void* value;
uint32_t hash; // The full hash value for key.
@@ -63,8 +66,12 @@ class HashMap {
// Removes the entry with matching key.
void Remove(void* key, uint32_t hash);
- // Empties the hash map (occupancy() == 0).
- void Clear();
+ // Empties the hash map (occupancy() == 0), and calls the function 'clear' on
+ // each of the values if given.
+ void Clear(ClearFun clear = NULL);
+
+ // The number of entries stored in the table.
+ intptr_t size() const { return occupancy_; }
// The capacity of the table. The implementation
// makes sure that occupancy is at most 80% of
« 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