mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
std.heap.DebugAllocator: fix account total_requested_bytes on resizeSmall
This commit is contained in:
committed by
Andrew Kelley
parent
5e9c484745
commit
4e3fadd90e
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user