DoxigAlpha

allocAdvancedWithRetAddr

Function parameters

Parameters

#
T:type
alignment:?Alignment
null means naturally aligned
n:usize
return_address:usize

Type definitions in this namespace

Types

#

Functions in this namespace

Functions

#
rawAlloc
This function is not intended to be called except from within the
rawResize
This function is not intended to be called except from within the
rawRemap
This function is not intended to be called except from within the
rawFree
This function is not intended to be called except from within the
create
Returns a pointer to undefined memory.
destroy
`ptr` should be the return value of `create`, or otherwise
alloc
Allocates an array of `n` items of type `T` and sets all the
allocSentinel
Allocates an array of `n + 1` items of type `T` and sets the first `n`
resize
Request to modify the size of an allocation.
remap
Request to modify the size of an allocation, allowing relocation.
realloc
This function requests a new size for an existing allocation, which
free
Free an array allocated with `alloc`.
dupe
Copies `m` to newly allocated memory.
dupeZ
Copies `m` to newly allocated memory, with a null-terminated element.

Error sets in this namespace

Error Sets

#

Source

Implementation

#
pub inline fn allocAdvancedWithRetAddr(
    self: Allocator,
    comptime T: type,
    /// null means naturally aligned
    comptime alignment: ?Alignment,
    n: usize,
    return_address: usize,
) Error![]align(if (alignment) |a| a.toByteUnits() else @alignOf(T)) T {
    const a = comptime (alignment orelse Alignment.of(T));
    const ptr: [*]align(a.toByteUnits()) T = @ptrCast(try self.allocWithSizeAndAlignment(@sizeOf(T), a, n, return_address));
    return ptr[0..n];
}