std.mem.Allocator
The entries of std.mem.Allocator in the Zig reference. This page has 32 cards.
pub fn alignedAlloc(self: Allocator, comptime T: type, comptime alignment: ?Alignment, n: usize) Error![]align(if (alignment) |a| a.toByteUnits() else @alignOf(T)) T
- Kind
- function
- Module
std.mem.Allocator
pub fn alignedCreate(self: Allocator, comptime T: type, comptime alignment: ?Alignment) Error!*align(if (alignment) |a| a.toByteUnits() else @alignOf(T)) T
- Kind
- function
- Module
std.mem.Allocator
pub fn alloc(self: Allocator, comptime T: type, n: usize) Error![]T
Allocates an array of `n` items of type `T` and sets all the items to `undefined`.
- Kind
- function
- Module
std.mem.Allocator
pub fn allocAdvancedWithRetAddr(self: Allocator, comptime T: type, comptime alignment: ?Alignment, n: usize, return_address: usize) Error![]align(if (alignment) |a| a.toByteUnits() else @alignOf(T)) T
- Kind
- function
- Module
std.mem.Allocator
pub fn allocBytesAligned(self: Allocator, comptime alignment: Alignment, byte_count: usize, return_address: usize) Error![*]align(alignment.toByteUnits()) u8
- Kind
- function
- Module
std.mem.Allocator
pub fn allocSentinel(self: Allocator, comptime Elem: type, n: usize, comptime sentinel: Elem) Error![:sentinel]Elem
Allocates an array of `n + 1` items of type `T` and sets the first `n` items to `undefined` and the last item to `sentinel`.
- Kind
- function
- Module
std.mem.Allocator
pub fn allocWithOptions(self: Allocator, comptime Elem: type, n: usize, comptime optional_alignment: ?Alignment, comptime optional_sentinel: ?Elem) Error!AllocWithOptionsPayload(Elem, optional_alignment, optional_sentinel)
- Kind
- function
- Module
std.mem.Allocator
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)
- Kind
- function
- Module
std.mem.Allocator
pub fn create(a: Allocator, comptime T: type) Error!*T
Returns a pointer to undefined memory.
- Kind
- function
- Module
std.mem.Allocator
pub fn createAdvancedWithRetAddr(self: Allocator, comptime T: type, comptime alignment: ?Alignment, return_address: usize) Error!*align(if (alignment) |a| a.toByteUnits() else @alignOf(T)) T
- Kind
- function
- Module
std.mem.Allocator
pub fn destroy(self: Allocator, ptr: anytype) void
`ptr` should be the return value of `create`, or otherwise have the same address and alignment property.
- Kind
- function
- Module
std.mem.Allocator
pub fn dupe(allocator: Allocator, comptime T: type, m: []const T) Error![]T
Copies `m` to newly allocated memory.
- Kind
- function
- Module
std.mem.Allocator
pub fn dupeSentinel(allocator: Allocator, comptime T: type, m: []const T, comptime sentinel: T) Error![:sentinel]T
Copies `m` to newly allocated memory, with a sentinel-terminated element.
- Kind
- function
- Module
std.mem.Allocator
- Kind
- error set
- Module
std.mem.Allocator
An allocator that always fails to allocate.
- Kind
- constant
- Module
std.mem.Allocator
pub fn free(self: Allocator, memory: anytype) void
Free an array allocated with `alloc`.
- Kind
- function
- Module
std.mem.Allocator
- Kind
- type
- Module
std.mem.Allocator
pub fn noAlloc(self: *anyopaque, len: usize, alignment: Alignment, ret_addr: usize) ?[*]u8
- Kind
- function
- Module
std.mem.Allocator
pub fn noFree(self: *anyopaque, memory: []u8, alignment: Alignment, ret_addr: usize) void
- Kind
- function
- Module
std.mem.Allocator
pub fn noRemap(self: *anyopaque, memory: []u8, alignment: Alignment, new_len: usize, ret_addr: usize) ?[*]u8
- Kind
- function
- Module
std.mem.Allocator
pub fn noResize(self: *anyopaque, memory: []u8, alignment: Alignment, new_len: usize, ret_addr: usize) bool
- Kind
- function
- Module
std.mem.Allocator
pub fn print(a: Allocator, comptime format: []const u8, args: anytype) Error![]u8
Allocates a formatted string which is returned on success.
- Kind
- function
- Module
std.mem.Allocator
pub fn printSentinel(a: Allocator, comptime format: []const u8, args: anytype, comptime sentinel: u8) Allocator.Error![:sentinel]u8
Like `print` but returned slice has the provided sentinel.
- Kind
- function
- Module
std.mem.Allocator
pub fn rawAlloc(a: Allocator, len: usize, alignment: Alignment, ret_addr: usize) ?[*]u8
This function is not intended to be called except from within the implementation of an `Allocator`.
- Kind
- function
- Module
std.mem.Allocator
pub fn rawFree(a: Allocator, memory: []u8, alignment: Alignment, ret_addr: usize) void
This function is not intended to be called except from within the implementation of an `Allocator`.
- Kind
- function
- Module
std.mem.Allocator
pub fn rawRemap(a: Allocator, memory: []u8, alignment: Alignment, new_len: usize, ret_addr: usize) ?[*]u8
This function is not intended to be called except from within the implementation of an `Allocator`.
- Kind
- function
- Module
std.mem.Allocator
pub fn rawResize(a: Allocator, memory: []u8, alignment: Alignment, new_len: usize, ret_addr: usize) bool
This function is not intended to be called except from within the implementation of an `Allocator`.
- Kind
- function
- Module
std.mem.Allocator
pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) Error!Slice(AbsorbSentinel(@TypeOf(old_mem)))
This function requests a new size for an existing allocation, which can be larger, smaller, or the same size as the old memory allocation.
- Kind
- function
- Module
std.mem.Allocator
pub fn reallocAdvanced(self: Allocator, old_mem: anytype, new_n: usize, return_address: usize) Error!Slice(AbsorbSentinel(@TypeOf(old_mem)))
- Kind
- function
- Module
std.mem.Allocator
pub fn remap(self: Allocator, allocation: anytype, new_len: usize) ?Slice(AbsorbSentinel(@TypeOf(allocation)))
Request to modify the size of an allocation, allowing relocation.
- Kind
- function
- Module
std.mem.Allocator
pub fn resize(self: Allocator, allocation: anytype, new_len: usize) bool
Request to modify the size of an allocation.
- Kind
- function
- Module
std.mem.Allocator
- Kind
- struct
- Module
std.mem.Allocator