mirror of
https://github.com/chromium/crashpad.git
synced 2025-01-15 01:57:58 +08:00
win: convert MinidumpSimpleStringDictionaryWriter to scoped_ptr
Had to move this one out to a scoped_ptr too, otherwise when it's instantiated in test code on the stack, d:\src\crashpad\crashpad\minidump\minidump_simple_string_dictionary_writer_test.cc(45) : warning C4815: 'dictionary_writer' : zero-sized array in stack object will have no elements (unless the object is an aggregate that has been aggregate initialized) R=mark@chromium.org BUG=crashpad:1 Review URL: https://codereview.chromium.org/895313004
This commit is contained in:
parent
75e6df2382
commit
3162f1259c
@ -91,7 +91,9 @@ bool MinidumpSimpleStringDictionaryEntryWriter::WriteObject(
|
|||||||
}
|
}
|
||||||
|
|
||||||
MinidumpSimpleStringDictionaryWriter::MinidumpSimpleStringDictionaryWriter()
|
MinidumpSimpleStringDictionaryWriter::MinidumpSimpleStringDictionaryWriter()
|
||||||
: MinidumpWritable(), entries_(), simple_string_dictionary_base_() {
|
: MinidumpWritable(),
|
||||||
|
entries_(),
|
||||||
|
simple_string_dictionary_base_(new MinidumpSimpleStringDictionary()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MinidumpSimpleStringDictionaryWriter::~MinidumpSimpleStringDictionaryWriter() {
|
MinidumpSimpleStringDictionaryWriter::~MinidumpSimpleStringDictionaryWriter() {
|
||||||
@ -137,7 +139,7 @@ bool MinidumpSimpleStringDictionaryWriter::Freeze() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t entry_count = entries_.size();
|
size_t entry_count = entries_.size();
|
||||||
if (!AssignIfInRange(&simple_string_dictionary_base_.count, entry_count)) {
|
if (!AssignIfInRange(&simple_string_dictionary_base_->count, entry_count)) {
|
||||||
LOG(ERROR) << "entry_count " << entry_count << " out of range";
|
LOG(ERROR) << "entry_count " << entry_count << " out of range";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -148,7 +150,7 @@ bool MinidumpSimpleStringDictionaryWriter::Freeze() {
|
|||||||
size_t MinidumpSimpleStringDictionaryWriter::SizeOfObject() {
|
size_t MinidumpSimpleStringDictionaryWriter::SizeOfObject() {
|
||||||
DCHECK_GE(state(), kStateFrozen);
|
DCHECK_GE(state(), kStateFrozen);
|
||||||
|
|
||||||
return sizeof(simple_string_dictionary_base_) +
|
return sizeof(*simple_string_dictionary_base_) +
|
||||||
entries_.size() * sizeof(MinidumpSimpleStringDictionaryEntry);
|
entries_.size() * sizeof(MinidumpSimpleStringDictionaryEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,8 +171,8 @@ bool MinidumpSimpleStringDictionaryWriter::WriteObject(
|
|||||||
DCHECK_GE(state(), kStateWritable);
|
DCHECK_GE(state(), kStateWritable);
|
||||||
|
|
||||||
WritableIoVec iov;
|
WritableIoVec iov;
|
||||||
iov.iov_base = &simple_string_dictionary_base_;
|
iov.iov_base = simple_string_dictionary_base_.get();
|
||||||
iov.iov_len = sizeof(simple_string_dictionary_base_);
|
iov.iov_len = sizeof(*simple_string_dictionary_base_);
|
||||||
std::vector<WritableIoVec> iovecs(1, iov);
|
std::vector<WritableIoVec> iovecs(1, iov);
|
||||||
|
|
||||||
for (const auto& key_entry : entries_) {
|
for (const auto& key_entry : entries_) {
|
||||||
|
@ -135,7 +135,7 @@ class MinidumpSimpleStringDictionaryWriter final
|
|||||||
// This object owns the MinidumpSimpleStringDictionaryEntryWriter objects.
|
// This object owns the MinidumpSimpleStringDictionaryEntryWriter objects.
|
||||||
std::map<std::string, MinidumpSimpleStringDictionaryEntryWriter*> entries_;
|
std::map<std::string, MinidumpSimpleStringDictionaryEntryWriter*> entries_;
|
||||||
|
|
||||||
MinidumpSimpleStringDictionary simple_string_dictionary_base_;
|
scoped_ptr<MinidumpSimpleStringDictionary> simple_string_dictionary_base_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MinidumpSimpleStringDictionaryWriter);
|
DISALLOW_COPY_AND_ASSIGN(MinidumpSimpleStringDictionaryWriter);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user