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 › deinitLog Public Function deinitLog Doc Source Public Function std.heap.SafeAllocator.deinitLog
pub fn deinitLog (s : *SafeAllocator , log : bool ) usize Params File heap/SafeAllocator.zig: 658
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685 pub fn deinitLog (s : *SafeAllocator , log : bool ) usize {
var leaks : usize = 0 ;
const thread_count = @atomicRmw (usize , &n_threads , .Or , 0 , .monotonic );
for (s .threads [0 ..@max (1 , thread_count )]) |*t | {
assert (t .mutex == .unlocked ); // use of allocator during `deinit`
var maybe_allocs = t .allocs_first ;
var n_entries = t .allocs_next ;
while (maybe_allocs ) |allocs | {
for (allocs .entries (s )[0 ..n_entries ]) |*ent | {
switch (ent .kind ) {
.free => {
@branchHint (.likely );
},
.bucket => leaks += s .deinitLeakedBucket (ent .toBucket (), log ),
.large_alloc => {
leaks += 1 ;
s .deinitLargeAlloc (ent .toLargeAlloc (), log );
},
}
}
maybe_allocs = allocs .next ;
n_entries = s .allocs_entry_count ;
s .backing .rawFree (@ptrCast (allocs .usizes (s )), .of (usize ), 0 );
}
}
return leaks ;
}
Same as
deinit, expect iflogisfalse, it will not log leaks.