diff options
author | Christopher Ferris <cferris@google.com> | 2016-04-07 17:14:53 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2016-04-12 15:36:53 -0700 |
commit | 55a89a48f41da349735627c2ae8985895955b1ca (patch) | |
tree | c946bd9b7e1353787f278e5face49cae5d8f238d /libc/malloc_debug/GuardData.cpp | |
parent | 03a16d3db7c5fff733d28250212821ec2ff5eccd (diff) |
Small refactor.
- Move all ScopedDisableDebugCalls into the debug_XXX calls. This avoids
any issues that might arise where every part of the code needs to properly
guard anything that might allocate. Instead everything is already guarded.
- Add a pointer to debug_data in all of the XXData classes. This avoids
calling individual functions passing in the debug_data pointer.
- Flip the NO_HEADER_OPTIONS to an explicit HEADER_OPTIONS list since fewer
options actually require a header.
- Move the extern of g_debug to the DebugData.h header.
Change-Id: Ia213a391b4a44d9ce122a709d09fe4f1b5426f36
Diffstat (limited to 'libc/malloc_debug/GuardData.cpp')
-rw-r--r-- | libc/malloc_debug/GuardData.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/libc/malloc_debug/GuardData.cpp b/libc/malloc_debug/GuardData.cpp index c70e8f108..48961b6ae 100644 --- a/libc/malloc_debug/GuardData.cpp +++ b/libc/malloc_debug/GuardData.cpp @@ -39,15 +39,14 @@ #include "malloc_debug.h" #include "GuardData.h" -GuardData::GuardData(int init_value, size_t num_bytes) { +GuardData::GuardData(DebugData* debug_data, int init_value, size_t num_bytes) + : OptionData(debug_data) { // Create a buffer for fast comparisons of the front guard. cmp_mem_.resize(num_bytes); memset(cmp_mem_.data(), init_value, cmp_mem_.size()); } void GuardData::LogFailure(const Header* header, const void* pointer, const void* data) { - ScopedDisableDebugCalls disable; - error_log(LOG_DIVIDER); error_log("+++ ALLOCATION %p SIZE %zu HAS A CORRUPTED %s GUARD", pointer, header->real_size(), GetTypeName()); @@ -70,8 +69,8 @@ void GuardData::LogFailure(const Header* header, const void* pointer, const void error_log(LOG_DIVIDER); } -FrontGuardData::FrontGuardData(const Config& config, size_t* offset) - : GuardData(config.front_guard_value, config.front_guard_bytes) { +FrontGuardData::FrontGuardData(DebugData* debug_data, const Config& config, size_t* offset) + : GuardData(debug_data, config.front_guard_value, config.front_guard_bytes) { // Create a buffer for fast comparisons of the front guard. cmp_mem_.resize(config.front_guard_bytes); memset(cmp_mem_.data(), config.front_guard_value, cmp_mem_.size()); @@ -80,22 +79,22 @@ FrontGuardData::FrontGuardData(const Config& config, size_t* offset) *offset += config.front_guard_bytes; } -bool FrontGuardData::Valid(DebugData& debug, const Header* header) { - return GuardData::Valid(debug.GetFrontGuard(header)); +bool FrontGuardData::Valid(const Header* header) { + return GuardData::Valid(debug_->GetFrontGuard(header)); } -void FrontGuardData::LogFailure(DebugData& debug, const Header* header) { - GuardData::LogFailure(header, debug.GetPointer(header), debug.GetFrontGuard(header)); +void FrontGuardData::LogFailure(const Header* header) { + GuardData::LogFailure(header, debug_->GetPointer(header), debug_->GetFrontGuard(header)); } -RearGuardData::RearGuardData(const Config& config) - : GuardData(config.rear_guard_value, config.rear_guard_bytes) { +RearGuardData::RearGuardData(DebugData* debug_data, const Config& config) + : GuardData(debug_data, config.rear_guard_value, config.rear_guard_bytes) { } -bool RearGuardData::Valid(DebugData& debug, const Header* header) { - return GuardData::Valid(debug.GetRearGuard(header)); +bool RearGuardData::Valid(const Header* header) { + return GuardData::Valid(debug_->GetRearGuard(header)); } -void RearGuardData::LogFailure(DebugData& debug, const Header* header) { - GuardData::LogFailure(header, debug.GetPointer(header), debug.GetRearGuard(header)); +void RearGuardData::LogFailure(const Header* header) { + GuardData::LogFailure(header, debug_->GetPointer(header), debug_->GetRearGuard(header)); } |