summaryrefslogtreecommitdiff
path: root/libc/malloc_debug/malloc_debug.h
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-03-07 13:38:48 -0800
committerChristopher Ferris <cferris@google.com>2018-04-02 18:59:23 -0700
commit4da2503d70dc4bc1444454876e3794b69227d90d (patch)
treed904c750ebac96aee76df44baad1320c0db211a3 /libc/malloc_debug/malloc_debug.h
parenta3f6f6c1b9135c90e410f5382b153db9a43a4db0 (diff)
Refactor malloc debug.
Changes - Refactor the code so that only guards require creating a special header for every pointer allocated. - Store only a single copy of every backtrace. This saves memory so that turning on the backtrace option doesn't result in 10X memory usage. - Added new option track_allocs that only verifies pointers are valid for free/malloc_usable_size/realloc. - Remove suffix from test names. - Add the TRACK_ALLOCS options to all guard options. - Add new option verify_pointers that is a lightweight way to verify pointers that are passed to allocation routines. - Do auto-formatting of the code. - Updated documentation for all of these changes. Bug: 74361929 Test: Ran unit tests. Test: Ran libmemunreachable unit tests. Test: Ran an app with backtrace enabled. Change-Id: I3246c48ae4f9811f64622d90d0a9b4d9d818702c
Diffstat (limited to 'libc/malloc_debug/malloc_debug.h')
-rw-r--r--libc/malloc_debug/malloc_debug.h7
1 files changed, 0 insertions, 7 deletions
diff --git a/libc/malloc_debug/malloc_debug.h b/libc/malloc_debug/malloc_debug.h
index 18a6c2c7f..ac210e246 100644
--- a/libc/malloc_debug/malloc_debug.h
+++ b/libc/malloc_debug/malloc_debug.h
@@ -37,13 +37,10 @@
// part of the header does not exist, the other parts of the header
// will still be in this order.
// Header (Required)
-// BacktraceHeader (Optional: For the allocation backtrace)
// uint8_t data (Optional: Front guard, will be a multiple of MINIMUM_ALIGNMENT_BYTES)
// allocation data
// uint8_t data (Optional: End guard)
//
-// If backtracing is enabled, then both BacktraceHeaders will be present.
-//
// In the initialization function, offsets into the header will be set
// for each different header location. The offsets are always from the
// beginning of the Header section.
@@ -52,10 +49,6 @@ struct Header {
void* orig_pointer;
size_t size;
size_t usable_size;
- size_t real_size() const { return size & ~(1U << 31); }
- void set_zygote_child_alloc() { size |= 1U << 31; }
- bool zygote_child_alloc() const { return size & (1U << 31); }
- static size_t max_size() { return (1U << 31) - 1; }
} __attribute__((packed));
struct BacktraceHeader {