fn populate(
memory: []align(@alignOf(AllocFooter)) u8,
len: usize,
alignment: Alignment,
ra: usize,
/// `true` for large allocations
is_extended: bool,
/// `false` for large allocations
prev_extended: bool,
container: Extended.Container,
s: *SafeAllocator,
) *AllocFooter memory: []align(@alignOf(AllocFooter)) u8len: usizealignment: Alignmentra: usizeis_extended: booltrue for large allocations
prev_extended: boolfalse for large allocations
container: Extended.Containers: *SafeAllocator579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618 fn populate(
memory: []align(@alignOf(AllocFooter)) u8,
len: usize,
alignment: Alignment,
ra: usize,
/// `true` for large allocations
is_extended: bool,
/// `false` for large allocations
prev_extended: bool,
container: Extended.Container,
s: *SafeAllocator,
) *AllocFooter {
const footer: *AllocFooter = @ptrCast(@alignCast(memory[allocOffset(len)..].ptr));
if (!is_extended) {
footer.data = .{
.len = @fromBackingInt(@intCast(len)),
.alignment = @intCast(@backingInt(alignment)),
.prev_extended = prev_extended,
};
assert(!footer.isExtended());
} else {
footer.data = .{
.len = @fromBackingInt(@intCast(Data.Len.extended_start + (@backingInt(alignment) >> 2))),
.alignment = @truncate(@backingInt(alignment)),
.prev_extended = prev_extended,
};
assert(footer.isExtended());
footer.extended().* = .{
.len = len,
.container = container,
};
}
captureStackTrace(footer.allocTrace(s), ra);
footer.checksum = footer.actualChecksum(s) ^ s.canary;
footer.modify.setNone();
return footer;
}
It is the caller's responsibility to
.acquirefence the respectiveBucket.alloc_count.