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 standard library.
std › heap › SafeAllocator › FuzzMultiThreadedAllocator › resize Private Function resize Doc Source Private Function std.heap.SafeAllocator.FuzzMultiThreadedAllocator.resize
fn resize (ctx : *anyopaque , memory : []u8 , _ : Alignment , new_len : usize , _ : usize ) bool Params ctx : *anyopaque memory : []u8 _ : Alignment new_len : usize _ : usize File heap/SafeAllocator.zig: 1947
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964 fn resize (ctx : *anyopaque , memory : []u8 , _ : Alignment , new_len : usize , _ : usize ) bool {
@disableInstrumentation ();
const f : *FuzzMultiThreadedAllocator = @ptrCast (@alignCast (ctx ));
const start = memory .ptr - f .buf .ptr ;
const old_end = start + memory .len ;
const new_end = start +| new_len ;
if (new_end > f .buf .len or f .maybeFail ()) {
return false ;
}
if (new_len <= memory .len ) {
// The fill is not decreased so memory is not reused.
return true ;
}
return @cmpxchgStrong (usize , &f .fill , old_end , new_end , .monotonic , .monotonic ) == null ;
}