commit 4e3fadd90ea6ddb24b5f98b049ad3374d1db0ab8 (tree) parent 5e9c484745b2a2dd997d1870b70f0303fa8ae2c7 Author: Brian Orora <brianorora@gmail.com> Date: Sat, 24 Jan 2026 20:10:45 +0300 std.heap.DebugAllocator: fix account `total_requested_bytes` on `resizeSmall` Diffstat:
| M | lib/std/heap/debug_allocator.zig | | | 9 | ++++++++- |
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/std/heap/debug_allocator.zig b/lib/std/heap/debug_allocator.zig @@ -1010,7 +1010,14 @@ pub fn DebugAllocator(comptime config: Config) type { size_class_index: usize, ) bool { const new_size_class_index: usize = @max(@bitSizeOf(usize) - @clz(new_len - 1), @intFromEnum(alignment)); - if (!config.safety) return new_size_class_index == size_class_index; + if (!config.safety) { + if (new_size_class_index != size_class_index) return false; + // Still account for total even if safety is off + if (config.enable_memory_limit) + self.total_requested_bytes = self.total_requested_bytes - memory.len + new_len; + return true; + } + const slot_count = slot_counts[size_class_index]; const memory_addr = @intFromPtr(memory.ptr); const page_addr = memory_addr & ~(page_size - 1);