authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-06-08 13:30:28+10:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-13 10:57:11-07:00
log28eed1f7b3a8654b941960232d7c707d88649d8d
treec6a46ecebdc3594ff324eec170b92572cc549a49
parent8cf72cdfb13409aad9a5e2abc125a516e13c3aa6

std.mem.ValidationAllocator: forward free() calls

Failing to forward free calls to the underlying allocator makes `ValidationAllocator` unusable for testing allocators while checking for leaks. This change allows allocators that wrap `std.testing.allocator` to be tested with `std.heap.testAllocator()` in test decls without reporting erroneous leaks.

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/mem.zig+3-3
......@@ -96,10 +96,10 @@ pub fn ValidationAllocator(comptime T: type) type {
9696 log2_buf_align: u8,
9797 ret_addr: usize,
9898 ) void {
99 _ = ctx;
100 _ = log2_buf_align;
101 _ = ret_addr;
99 const self = @ptrCast(*Self, @alignCast(@alignOf(Self), ctx));
102100 assert(buf.len > 0);
101 const underlying = self.getUnderlyingAllocatorPtr();
102 underlying.rawFree(buf, log2_buf_align, ret_addr);
103103 }
104104
105105 pub fn reset(self: *Self) void {