authorgravatar for brianorora@gmail.comBrian Orora <brianorora@gmail.com> 2026-01-24 20:10:45+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-27 00:09:48+01:00
log4e3fadd90ea6ddb24b5f98b049ad3374d1db0ab8
tree4d1ff97cda03473a816a64d05d6f8759bf6262d5
parent5e9c484745b2a2dd997d1870b70f0303fa8ae2c7

std.heap.DebugAllocator: fix account `total_requested_bytes` on `resizeSmall`


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

lib/std/heap/debug_allocator.zig+8-1
......@@ -1010,7 +1010,14 @@ pub fn DebugAllocator(comptime config: Config) type {
10101010 size_class_index: usize,
10111011 ) bool {
10121012 const new_size_class_index: usize = @max(@bitSizeOf(usize) - @clz(new_len - 1), @intFromEnum(alignment));
1013 if (!config.safety) return new_size_class_index == size_class_index;
1013 if (!config.safety) {
1014 if (new_size_class_index != size_class_index) return false;
1015 // Still account for total even if safety is off
1016 if (config.enable_memory_limit)
1017 self.total_requested_bytes = self.total_requested_bytes - memory.len + new_len;
1018 return true;
1019 }
1020
10141021 const slot_count = slot_counts[size_class_index];
10151022 const memory_addr = @intFromPtr(memory.ptr);
10161023 const page_addr = memory_addr & ~(page_size - 1);