authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-09 23:07:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-09 23:07:18-07:00
log40d74e428759d473b1704878814bd4a25bb0245c
treebd80fa078b24aa24b7c638d1e27da100b422c124
parent36cf22c55cc9c39d8c124b74d08f0413ee618580

std: refactor to use Alignment.of


3 files changed, 3 insertions(+), 3 deletions(-)

lib/std/heap.zig+1-1
......@@ -287,7 +287,7 @@ fn rawCAlloc(
287287) ?[*]u8 {
288288 _ = context;
289289 _ = return_address;
290 assert(alignment.compare(.lte, comptime .fromByteUnits(@alignOf(std.c.max_align_t))));
290 assert(alignment.compare(.lte, .of(std.c.max_align_t)));
291291 // Note that this pointer cannot be aligncasted to max_align_t because if
292292 // len is < max_align_t then the alignment can be smaller. For example, if
293293 // max_align_t is 16, but the user requests 8 bytes, there is no built-in
lib/std/heap/arena_allocator.zig+1-1
......@@ -42,7 +42,7 @@ pub const ArenaAllocator = struct {
4242 data: usize,
4343 node: std.SinglyLinkedList.Node = .{},
4444 };
45 const BufNode_alignment: Alignment = .fromByteUnits(@alignOf(BufNode));
45 const BufNode_alignment: Alignment = .of(BufNode);
4646
4747 pub fn init(child_allocator: Allocator) ArenaAllocator {
4848 return (State{}).promote(child_allocator);
lib/std/mem/Allocator.zig+1-1
......@@ -253,7 +253,7 @@ pub inline fn allocAdvancedWithRetAddr(
253253 n: usize,
254254 return_address: usize,
255255) Error![]align(if (alignment) |a| a.toByteUnits() else @alignOf(T)) T {
256 const a = comptime (alignment orelse Alignment.fromByteUnits(@alignOf(T)));
256 const a = comptime (alignment orelse Alignment.of(T));
257257 const ptr: [*]align(a.toByteUnits()) T = @ptrCast(try self.allocWithSizeAndAlignment(@sizeOf(T), a, n, return_address));
258258 return ptr[0..n];
259259}