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

Unified Diff: minidump/minidump_simple_string_dictionary_writer.cc

Issue 674153002: minidump: Change the ownership model (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 2 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
Index: minidump/minidump_simple_string_dictionary_writer.cc
diff --git a/minidump/minidump_simple_string_dictionary_writer.cc b/minidump/minidump_simple_string_dictionary_writer.cc
index ef3a1eca176d4ad0cb12cb6a941b3f81ab7ecbfc..9218bd9786597a7c08e3cc484194d217e33a1eae 100644
--- a/minidump/minidump_simple_string_dictionary_writer.cc
+++ b/minidump/minidump_simple_string_dictionary_writer.cc
@@ -15,6 +15,7 @@
#include "minidump/minidump_simple_string_dictionary_writer.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "util/file/file_writer.h"
#include "util/numeric/safe_assignment.h"
@@ -92,13 +93,21 @@ MinidumpSimpleStringDictionaryWriter::MinidumpSimpleStringDictionaryWriter()
}
MinidumpSimpleStringDictionaryWriter::~MinidumpSimpleStringDictionaryWriter() {
+ STLDeleteContainerPairSecondPointers(entries_.begin(), entries_.end());
}
void MinidumpSimpleStringDictionaryWriter::AddEntry(
- MinidumpSimpleStringDictionaryEntryWriter* entry) {
+ scoped_ptr<MinidumpSimpleStringDictionaryEntryWriter> entry) {
DCHECK_GE(state(), kStateMutable);
- entries_[entry->Key()] = entry;
+ const std::string& key = entry->Key();
+ auto iterator = entries_.find(key);
+ if (iterator != entries_.end()) {
+ delete iterator->second;
+ iterator->second = entry.release();
+ } else {
+ entries_[key] = entry.release();
+ }
}
bool MinidumpSimpleStringDictionaryWriter::Freeze() {
« no previous file with comments | « minidump/minidump_simple_string_dictionary_writer.h ('k') | minidump/minidump_simple_string_dictionary_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698