| ... | @@ -315,8 +315,10 @@ fn pushFreeList(arena: *ArenaAllocator, first: *Node, last: *Node) void { | ... | @@ -315,8 +315,10 @@ fn pushFreeList(arena: *ArenaAllocator, first: *Node, last: *Node) void { |
| 315 | } | 315 | } |
| 316 | | 316 | |
| 317 | fn alignedIndex(buf_ptr: [*]u8, end_index: usize, alignment: Alignment) usize { | 317 | fn alignedIndex(buf_ptr: [*]u8, end_index: usize, alignment: Alignment) usize { |
| 318 | return end_index + | 318 | // Wrapping arithmetic to avoid overflows since `end_index` isn't bounded by |
| 319 | mem.alignPointerOffset(buf_ptr + end_index, alignment.toByteUnits()).?; | 319 | // `size`. This is always ok since the max alignment in byte units is also |
| | 320 | // the max value of `usize` so wrapped values are correctly aligned anyway. |
| | 321 | return alignment.forward(@intFromPtr(buf_ptr) +% end_index) -% @intFromPtr(buf_ptr); |
| 320 | } | 322 | } |
| 321 | | 323 | |
| 322 | fn alloc(ctx: *anyopaque, n: usize, alignment: Alignment, ret_addr: usize) ?[*]u8 { | 324 | fn alloc(ctx: *anyopaque, n: usize, alignment: Alignment, ret_addr: usize) ?[*]u8 { |