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/ › FixedBufferAllocator.zig › resize
resize
FixedBufferAllocator.resize
pub fn resize (
ctx : *anyopaque ,
buf : []u8 ,
alignment : mem .Alignment ,
new_size : usize ,
return_address : usize ,
) bool
File
Code
pub fn resize (
ctx : *anyopaque ,
buf : []u8 ,
alignment : mem .Alignment ,
new_size : usize ,
return_address : usize ,
) bool {
const self : *FixedBufferAllocator = @ptrCast (@alignCast (ctx ));
_ = alignment ;
_ = return_address ;
assert (@inComptime () or self .ownsSlice (buf ));
if (!self .isLastAllocation (buf )) {
if (new_size > buf .len ) return false ;
return true ;
}
if (new_size <= buf .len ) {
const sub = buf .len - new_size ;
self .end_index -= sub ;
return true ;
}
const add = new_size - buf .len ;
if (add + self .end_index > self .buffer .len ) return false ;
self .end_index += add ;
return true ;
}