authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-07 00:47:43-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-07 14:41:49-08:00
log1ffae59fec60816ff364b4ade93c6fc2fc1571cf
tree275f078ca603fcbf8d1e070a6c829526a120857c
parent839c453d880e22f2f120d62332b273380a215cc5

std.heap.SmpAllocator: fix using wrong size class indices


1 files changed, 4 insertions(+), 6 deletions(-)

lib/std/heap/SmpAllocator.zig+4-6
......@@ -215,13 +215,11 @@ fn free(context: *anyopaque, memory: []u8, alignment: mem.Alignment, ra: usize)
215215
216216fn sizeClassIndex(len: usize, alignment: mem.Alignment) usize {
217217 return @max(
218 @bitSizeOf(usize) - @clz(len - 1),
219 @intFromEnum(alignment),
220 min_class,
221 );
218 @bitSizeOf(usize) - @clz(len + (@sizeOf(usize) - 1)),
219 @intFromEnum(alignment) + 1,
220 ) - min_class;
222221}
223222
224223fn slotSize(class: usize) usize {
225 const Log2USize = std.math.Log2Int(usize);
226 return @as(usize, 1) << @as(Log2USize, @intCast(class));
224 return @as(usize, 1) << @intCast(class + min_class);
227225}