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

Unified Diff: runtime/platform/hashmap.cc

Issue 2229973002: Revert: Fixes memory leaks in the eventhandler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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/platform/hashmap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/hashmap.cc
diff --git a/runtime/platform/hashmap.cc b/runtime/platform/hashmap.cc
index 34f7ea1284f9f48b38890c95496935551556dcd3..693367fc74108fbe66920a286f00784e41a32c5d 100644
--- a/runtime/platform/hashmap.cc
+++ b/runtime/platform/hashmap.cc
@@ -15,7 +15,7 @@ HashMap::HashMap(MatchFun match, uint32_t initial_capacity) {
HashMap::~HashMap() {
- delete[] map_;
+ free(map_);
}
@@ -106,19 +106,14 @@ void HashMap::Remove(void* key, uint32_t hash) {
// Clear the candidate which will not break searching the hash table.
candidate->key = NULL;
- candidate->value = NULL;
occupancy_--;
}
-void HashMap::Clear(ClearFun clear) {
+void HashMap::Clear() {
// Mark all entries as empty.
const Entry* end = map_end();
for (Entry* p = map_; p < end; p++) {
- if ((clear != NULL) && (p->key != NULL)) {
- clear(p->value);
- }
- p->value = NULL;
p->key = NULL;
}
occupancy_ = 0;
@@ -164,14 +159,14 @@ HashMap::Entry* HashMap::Probe(void* key, uint32_t hash) {
void HashMap::Initialize(uint32_t capacity) {
ASSERT(dart::Utils::IsPowerOfTwo(capacity));
- map_ = new Entry[capacity];
+ map_ = reinterpret_cast<Entry*>(malloc(capacity * sizeof(Entry)));
if (map_ == NULL) {
// TODO(sgjesse): Handle out of memory.
FATAL("Cannot allocate memory for hashmap");
return;
}
capacity_ = capacity;
- occupancy_ = 0;
+ Clear();
}
@@ -191,7 +186,7 @@ void HashMap::Resize() {
}
// Delete old map.
- delete[] map;
+ free(map);
}
} // namespace dart
« no previous file with comments | « runtime/platform/hashmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698