diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-09-25 00:21:57 +0200 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2020-09-25 10:58:07 +0200 |
| commit | bd9003ed5b16a6e187999fb1190d89eb80bd587b (patch) | |
| tree | f5b125d1f2bf1065223de6526dbba3ae33caf17c /lib/std/heap.zig | |
| parent | bd89bd6fdbcc0ce5ea7763a8043fd46099022b19 (diff) | |
| download | zig-bd9003ed5b16a6e187999fb1190d89eb80bd587b.tar.gz zig-bd9003ed5b16a6e187999fb1190d89eb80bd587b.zip | |
std: ArenaAllocator tries to resize before allocating
Closes #5116
Diffstat (limited to 'lib/std/heap.zig')
| -rw-r--r-- | lib/std/heap.zig | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/std/heap.zig b/lib/std/heap.zig index 16de215cc2..cf32cff645 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -919,6 +919,13 @@ pub fn testAllocator(base_allocator: *mem.Allocator) !void { const zero_bit_ptr = try allocator.create(u0); zero_bit_ptr.* = 0; allocator.destroy(zero_bit_ptr); + + const oversize = try allocator.allocAdvanced(u32, null, 5, .at_least); + testing.expect(oversize.len >= 5); + for (oversize) |*item| { + item.* = 0xDEADBEEF; + } + allocator.free(oversize); } pub fn testAllocatorAligned(base_allocator: *mem.Allocator, comptime alignment: u29) !void { |
