Returns an allocator that wraps base_allocator (the current allocator when unset) and fills memory with overwrite_byte when it is allocated and again when it is freed, so reads of uninitialized or freed memory show an obvious pattern. Freeing a pointer it did not hand out, or twice, is reported. Free it with deinit_overwriting_allocator.
allocator := get_overwriting_allocator();
memory := cast(*u8) allocator.proc(.ALLOCATE, 4, 0, null, allocator.data);
assert(memory[0] == 0xcd);
memory[0] = 1;
allocator.proc(.FREE, 0, 4, memory, allocator.data);
deinit_overwriting_allocator(allocator);get_overwriting_allocator :: (
base_allocator: Allocator = .{},
overwrite_byte: u8 = 0xcd
) -> Allocator
Parameters
- base_allocator: Allocator = .{}
- overwrite_byte: u8 = 0xcd
Returns
- Allocator