feature. See also
. The project being documented here (as the example) is the Zig library itself.
Allocator.allocWithOptionsRetAddr
pub fn allocWithOptionsRetAddr(
self: Allocator,
comptime Elem: type,
n: usize,
comptime optional_alignment: ?Alignment,
comptime optional_sentinel: ?Elem,
return_address: usize,
) Error!AllocWithOptionsPayload(Elem, optional_alignment, optional_sentinel)
File
Code
pub fn allocWithOptionsRetAddr(
self: Allocator,
comptime Elem: type,
n: usize,
comptime optional_alignment: ?Alignment,
comptime optional_sentinel: ?Elem,
return_address: usize,
) Error!AllocWithOptionsPayload(Elem, optional_alignment, optional_sentinel) {
if (optional_sentinel) |sentinel| {
const ptr = try self.allocAdvancedWithRetAddr(Elem, optional_alignment, n + 1, return_address);
ptr[n] = sentinel;
return ptr[0..n :sentinel];
} else {
return self.allocAdvancedWithRetAddr(Elem, optional_alignment, n, return_address);
}
}