get
This function both fetches a Allocator interface to this
allocator and resets the internal buffer allocator.
Function parameters
Parameters
- self:*Self
Type definitions in this namespace
Types
- GeneralPurposeAllocatorConfig
- Deprecated; to be removed after 0.14.0 is tagged.
Functions in this namespace
Functions
- GeneralPurposeAllocator
- Deprecated; to be removed after 0.14.0 is tagged.
- pageSize
- If the page size is comptime-known, return value is comptime.
- defaultQueryPageSize
- The default implementation of `std.options.queryPageSize`.
- stackFallback
- Returns a `StackFallbackAllocator` allocating using either a
- StackFallbackAllocator
- An allocator that attempts to allocate using a
- testAllocator
- This one should not try alignments that exceed what C malloc can handle.
TODO Utilize this on Windows.
Values
- next_mmap_addr_hint
- TODO Utilize this on Windows.
- page_size_min
- comptime-known minimum page size of the target.
- page_size_max
- comptime-known maximum page size of the target.
- c_allocator
- Supports the full Allocator interface, including alignment, and exploiting
- raw_c_allocator
- Asserts allocations are within `@alignOf(std.c.max_align_t)` and directly
- page_allocator
- On operating systems that support memory mapping, this allocator makes a
- smp_allocator
- = .{ .ptr = undefined, .vtable = &SmpAllocator.vtable, }
- wasm_allocator
- This allocator is fast, small, and specific to WebAssembly.
Source
Implementation
pub fn get(self: *Self) Allocator {
if (std.debug.runtime_safety) {
assert(!self.get_called); // `get` called multiple times; instead use `const allocator = stackFallback(N).get();`
self.get_called = true;
}
self.fixed_buffer_allocator = FixedBufferAllocator.init(self.buffer[0..]);
return .{
.ptr = self,
.vtable = &.{
.alloc = alloc,
.resize = resize,
.remap = remap,
.free = free,
},
};
}