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 › allocInner Private Function allocInner Doc Source Private Function std.heap.SafeAllocator.FuzzMultiThreadedAllocator.allocInner
fn allocInner (f : *FuzzMultiThreadedAllocator , len : usize , alignment : Alignment ) ?[*]u8 Params File heap/SafeAllocator.zig: 1918
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938 fn allocInner (f : *FuzzMultiThreadedAllocator , len : usize , alignment : Alignment ) ?[*]u8 {
var prev_fill = @atomicLoad (usize , &f .fill , .monotonic );
var start : usize = undefined ;
while (true ) {
const start_addr = alignment .forward (@intFromPtr (f .buf [prev_fill ..].ptr ));
start = @as ([*]u8 , @ptrFromInt (start_addr )) - f .buf .ptr ;
if (start +| len > f .buf .len or f .maybeFail ()) return null ;
prev_fill = @cmpxchgStrong (
usize ,
&f .fill ,
prev_fill ,
start + len ,
.monotonic ,
.monotonic ,
) orelse {
@branchHint (.likely );
break ;
};
}
return f .buf [start ..][0 ..len ].ptr ;
}