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 › ArenaAllocator › FuzzContext › doOneAlloc Private Function doOneAlloc Doc Source Private Function std.heap.ArenaAllocator.FuzzContext.doOneAlloc
fn doOneAlloc (ctx : *FuzzContext , len : usize , alignment : Alignment , index : Alloc .Index ) void Params File heap/ArenaAllocator.zig: 888
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914 fn doOneAlloc (ctx : *FuzzContext , len : usize , alignment : Alignment , index : Alloc .Index ) void {
@disableInstrumentation ();
assert (ctx .allocs [@backingInt (index )].common .len == .free );
const control_ptr = ctx .control_allocator .rawAlloc (len , alignment , @returnAddress ()) orelse
return ;
const sample_ptr = ctx .sample_allocator .rawAlloc (len , alignment , @returnAddress ()) orelse {
ctx .control_allocator .rawFree (control_ptr [0 ..len ], alignment , @returnAddress ());
return ;
};
ctx .allocs [@backingInt (index )] = .{
.control_ptr = control_ptr ,
.sample_ptr = sample_ptr ,
.common = .{
.len = @fromBackingInt (@intCast (len )),
.alignment = alignment ,
},
};
for (control_ptr [0 ..len ], sample_ptr [0 ..len ], 0 ..) |*control , *sample , i | {
control .* = @truncate (i );
sample .* = @truncate (i );
}
@atomicStore (Alloc .Index , &ctx .last_alloc_index , index , .release );
}