Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › heap.zig › testAllocatorAligned
testAllocatorAligned
heap.testAllocatorAligned
pub fn testAllocatorAligned (base_allocator : mem .Allocator ) !void
File
Code
pub fn testAllocatorAligned (base_allocator : mem .Allocator ) !void {
var validationAllocator = mem .validationWrap (base_allocator );
const allocator = validationAllocator .allocator ();
inline for ([_ ]Alignment { .@"1" , .@"2" , .@"4" , .@"8" , .@"16" , .@"32" , .@"64" }) |alignment | {
var slice = try allocator .alignedAlloc (u8 , alignment , 10 );
try testing .expect (slice .len == 10 );
slice = try allocator .realloc (slice , 100 );
try testing .expect (slice .len == 100 );
if (allocator .resize (slice , 10 )) {
slice = slice [0 ..10 ];
}
try testing .expect (allocator .resize (slice , 0 ));
slice = slice [0 ..0 ];
slice = try allocator .realloc (slice , 100 );
try testing .expect (slice .len == 100 );
if (allocator .resize (slice , 10 )) {
slice = slice [0 ..10 ];
}
try testing .expect (allocator .resize (slice , 0 ));
}
}