diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-11-27 01:07:35 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-11-29 23:30:38 -0700 |
| commit | ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86 (patch) | |
| tree | 3c174281ab0b9d51b6c78234b0648e197412eea8 /lib/std/multi_array_list.zig | |
| parent | deda6b514691c3a7ffc7931469886d0e7be2f67e (diff) | |
| download | zig-ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86.tar.gz zig-ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86.zip | |
std.mem.Allocator: allow shrink to fail
closes #13535
Diffstat (limited to 'lib/std/multi_array_list.zig')
| -rw-r--r-- | lib/std/multi_array_list.zig | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index 89c7869b6b..f0b4dac106 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -288,11 +288,10 @@ pub fn MultiArrayList(comptime S: type) type { assert(new_len <= self.capacity); assert(new_len <= self.len); - const other_bytes = gpa.allocAdvanced( + const other_bytes = gpa.alignedAlloc( u8, @alignOf(S), capacityInBytes(new_len), - .exact, ) catch { const self_slice = self.slice(); inline for (fields) |field_info, i| { @@ -360,11 +359,10 @@ pub fn MultiArrayList(comptime S: type) type { /// `new_capacity` must be greater or equal to `len`. pub fn setCapacity(self: *Self, gpa: Allocator, new_capacity: usize) !void { assert(new_capacity >= self.len); - const new_bytes = try gpa.allocAdvanced( + const new_bytes = try gpa.alignedAlloc( u8, @alignOf(S), capacityInBytes(new_capacity), - .exact, ); if (self.len == 0) { gpa.free(self.allocatedBytes()); |
