Same as deinit, expect if log is false, it will not log leaks.
pub fn deinitLog(s: *SafeAllocator, log: bool) usize
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;
}