diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-04-11 17:55:25 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-04-13 02:20:32 -0400 |
| commit | f32a5d349d2c359a2a1f627aa70e1a7a6f6330ea (patch) | |
| tree | 05a0fe7de04e6aa91775e954f78dd1a478d7e675 /lib/std/heap/debug_allocator.zig | |
| parent | ec2888858102035f296c01df5aacbd255c35d06f (diff) | |
| download | zig-f32a5d349d2c359a2a1f627aa70e1a7a6f6330ea.tar.gz zig-f32a5d349d2c359a2a1f627aa70e1a7a6f6330ea.zip | |
std: eradicate u29 and embrace std.mem.Alignment
Diffstat (limited to 'lib/std/heap/debug_allocator.zig')
| -rw-r--r-- | lib/std/heap/debug_allocator.zig | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/heap/debug_allocator.zig b/lib/std/heap/debug_allocator.zig index a6b2676b1d..3243f1b1bd 100644 --- a/lib/std/heap/debug_allocator.zig +++ b/lib/std/heap/debug_allocator.zig @@ -1120,7 +1120,7 @@ test "realloc" { defer std.testing.expect(gpa.deinit() == .ok) catch @panic("leak"); const allocator = gpa.allocator(); - var slice = try allocator.alignedAlloc(u8, @alignOf(u32), 1); + var slice = try allocator.alignedAlloc(u8, .of(u32), 1); defer allocator.free(slice); slice[0] = 0x12; @@ -1234,7 +1234,7 @@ test "shrink large object to large object with larger alignment" { const debug_allocator = fba.allocator(); const alloc_size = default_page_size * 2 + 50; - var slice = try allocator.alignedAlloc(u8, 16, alloc_size); + var slice = try allocator.alignedAlloc(u8, .@"16", alloc_size); defer allocator.free(slice); const big_alignment: usize = default_page_size * 2; @@ -1244,7 +1244,7 @@ test "shrink large object to large object with larger alignment" { var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) { try stuff_to_free.append(slice); - slice = try allocator.alignedAlloc(u8, 16, alloc_size); + slice = try allocator.alignedAlloc(u8, .@"16", alloc_size); } while (stuff_to_free.pop()) |item| { allocator.free(item); @@ -1308,7 +1308,7 @@ test "realloc large object to larger alignment" { var fba = std.heap.FixedBufferAllocator.init(&debug_buffer); const debug_allocator = fba.allocator(); - var slice = try allocator.alignedAlloc(u8, 16, default_page_size * 2 + 50); + var slice = try allocator.alignedAlloc(u8, .@"16", default_page_size * 2 + 50); defer allocator.free(slice); const big_alignment: usize = default_page_size * 2; @@ -1316,7 +1316,7 @@ test "realloc large object to larger alignment" { var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) { try stuff_to_free.append(slice); - slice = try allocator.alignedAlloc(u8, 16, default_page_size * 2 + 50); + slice = try allocator.alignedAlloc(u8, .@"16", default_page_size * 2 + 50); } while (stuff_to_free.pop()) |item| { allocator.free(item); @@ -1402,7 +1402,7 @@ test "large allocations count requested size not backing size" { var gpa: DebugAllocator(.{ .enable_memory_limit = true }) = .{}; const allocator = gpa.allocator(); - var buf = try allocator.alignedAlloc(u8, 1, default_page_size + 1); + var buf = try allocator.alignedAlloc(u8, .@"1", default_page_size + 1); try std.testing.expectEqual(default_page_size + 1, gpa.total_requested_bytes); buf = try allocator.realloc(buf, 1); try std.testing.expectEqual(1, gpa.total_requested_bytes); |
