std.heap.DebugAllocator: fix account total_requested_bytes on resizeSmall

This commit is contained in:
Brian Orora
2026-01-24 20:10:45 +03:00
committed by Andrew Kelley
parent 5e9c484745
commit 4e3fadd90e
+8 -1
View File
@@ -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);