summaryrefslogtreecommitdiff
path: root/libc/malloc_debug/GuardData.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-04-05 19:13:03 -0700
committerChristopher Ferris <cferris@google.com>2017-04-06 15:30:42 -0700
commit2b2b25b87827102671cdd4b25c01aa22a9971a63 (patch)
treed318825c7548379a307beee5b78580e51ce97a52 /libc/malloc_debug/GuardData.cpp
parente06c69d07324f3da67aa063202e698dedd831365 (diff)
Refactor Config from a struct to a class.
This should make it easier to add new options, and to add options that are complex. For example, I want to modify the behavior of record_allocs_file so that it also enables record_allocs to a default state. Test: All unit tests pass. Test: Enable the backtrace option and restart. Change-Id: Idf5cdeed06ade3bc2c8ae39d228734bf65209b4f
Diffstat (limited to 'libc/malloc_debug/GuardData.cpp')
-rw-r--r--libc/malloc_debug/GuardData.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/libc/malloc_debug/GuardData.cpp b/libc/malloc_debug/GuardData.cpp
index e207b8630..d6cef85c1 100644
--- a/libc/malloc_debug/GuardData.cpp
+++ b/libc/malloc_debug/GuardData.cpp
@@ -70,13 +70,13 @@ void GuardData::LogFailure(const Header* header, const void* pointer, const void
}
FrontGuardData::FrontGuardData(DebugData* debug_data, const Config& config, size_t* offset)
- : GuardData(debug_data, config.front_guard_value, config.front_guard_bytes) {
+ : 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());
+ cmp_mem_.resize(config.front_guard_bytes());
+ memset(cmp_mem_.data(), config.front_guard_value(), cmp_mem_.size());
// Assumes that front_bytes is a multiple of MINIMUM_ALIGNMENT_BYTES.
offset_ = *offset;
- *offset += config.front_guard_bytes;
+ *offset += config.front_guard_bytes();
}
bool FrontGuardData::Valid(const Header* header) {
@@ -88,7 +88,7 @@ void FrontGuardData::LogFailure(const Header* header) {
}
RearGuardData::RearGuardData(DebugData* debug_data, const Config& config)
- : GuardData(debug_data, config.rear_guard_value, config.rear_guard_bytes) {
+ : GuardData(debug_data, config.rear_guard_value(), config.rear_guard_bytes()) {
}
bool RearGuardData::Valid(const Header* header) {