mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-28 02:05:04 +01:00
Make memory allocation/deallocation consistent: use new char[] instead of operator new()
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@724 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
3b4ac42ff8
commit
bbd8e82a7f
6 changed files with 26 additions and 28 deletions
|
|
@ -53,33 +53,28 @@
|
|||
namespace google_breakpad {
|
||||
|
||||
bool ModuleComparer::Compare(const string &symbol_data) {
|
||||
// Empty CodeModule with only a name "test":
|
||||
BasicCodeModule code_module(0, 0, "test", "", "", "", "");
|
||||
scoped_ptr<BasicModule> basic_module(new BasicModule("test_module"));
|
||||
scoped_ptr<FastModule> fast_module(new FastModule("test_module"));
|
||||
|
||||
// Load BasicSourceLineResolver::Module.
|
||||
BPLOG(INFO) << "Unserialized size = " << symbol_data.size() << " Bytes";
|
||||
basic_resolver_->LoadModuleUsingMapBuffer(&code_module, symbol_data);
|
||||
BasicModule *old_module = dynamic_cast<BasicModule*>(
|
||||
basic_resolver_->modules_->at("test"));
|
||||
// Load symbol data into basic_module
|
||||
scoped_array<char> buffer(new char[symbol_data.size() + 1]);
|
||||
strcpy(buffer.get(), symbol_data.c_str());
|
||||
ASSERT_TRUE(basic_module->LoadMapFromMemory(buffer.get()));
|
||||
buffer.reset();
|
||||
|
||||
// Serialize BasicSourceLineResolver::Module.
|
||||
unsigned int serialized_size = 0;
|
||||
char *mem = serializer_.Serialize(*old_module, &serialized_size);
|
||||
ASSERT_TRUE(mem);
|
||||
scoped_array<char> serialized_data(
|
||||
serializer_.Serialize(*(basic_module.get()), &serialized_size));
|
||||
ASSERT_TRUE(serialized_data.get());
|
||||
BPLOG(INFO) << "Serialized size = " << serialized_size << " Bytes";
|
||||
|
||||
// Load FastSourceLineResolver::Module using serialized data.
|
||||
ASSERT_TRUE(fast_resolver_->LoadModuleUsingMemoryBuffer(&code_module, mem));
|
||||
FastModule *new_module = dynamic_cast<FastModule*>(
|
||||
fast_resolver_->modules_->at("test"));
|
||||
ASSERT_TRUE(fast_module->LoadMapFromMemory(serialized_data.get()));
|
||||
|
||||
// Compare FastSourceLineResolver::Module with
|
||||
// BasicSourceLineResolver::Module.
|
||||
ASSERT_TRUE(CompareModule(old_module, new_module));
|
||||
|
||||
// Clean up.
|
||||
basic_resolver_->UnloadModule(&code_module);
|
||||
fast_resolver_->UnloadModule(&code_module);
|
||||
ASSERT_TRUE(CompareModule(basic_module.get(), fast_module.get()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue