authorgravatar for 119271574+notcancername@users.noreply.github.comnotcancername <119271574+notcancername@users.noreply.github.com> 2022-11-28 03:52:18+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-28 14:31:57+02:00
logf98aac9db4ddc4790684e5411798087ec18b011a
tree50ba3137e3bb53e4ab15ddb04a0a322faff911b6
parent3ae4931dc1a3b1b338d2fd3a49a5a79b445bebf6

document std.heap.StackFallbackAllocator


1 files changed, 7 insertions(+), 0 deletions(-)

lib/std/heap.zig+7
...@@ -855,6 +855,9 @@ pub const FixedBufferAllocator = struct {...@@ -855,6 +855,9 @@ pub const FixedBufferAllocator = struct {
855855
856pub const ThreadSafeFixedBufferAllocator = @compileError("ThreadSafeFixedBufferAllocator has been replaced with `threadSafeAllocator` on FixedBufferAllocator");856pub const ThreadSafeFixedBufferAllocator = @compileError("ThreadSafeFixedBufferAllocator has been replaced with `threadSafeAllocator` on FixedBufferAllocator");
857857
858/// Returns a `StackFallbackAllocator` allocating using either a
859/// `FixedBufferAllocator` on an array of size `size` and falling back to
860/// `fallback_allocator` if that fails.
858pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackFallbackAllocator(size) {861pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackFallbackAllocator(size) {
859 return StackFallbackAllocator(size){862 return StackFallbackAllocator(size){
860 .buffer = undefined,863 .buffer = undefined,
...@@ -863,6 +866,10 @@ pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackF...@@ -863,6 +866,10 @@ pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackF
863 };866 };
864}867}
865868
869/// An allocator that attempts to allocate using a
870/// `FixedBufferAllocator` using an array of size `size`. If the
871/// allocation fails, it will fall back to using
872/// `fallback_allocator`. Easily created with `stackFallback`.
866pub fn StackFallbackAllocator(comptime size: usize) type {873pub fn StackFallbackAllocator(comptime size: usize) type {
867 return struct {874 return struct {
868 const Self = @This();875 const Self = @This();