authorgravatar for 119271574+notcancername@users.noreply.github.comnotcancername <119271574+notcancername@users.noreply.github.com> 2022-11-28 03:52:18+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-09 14:44:05-07:00
loge5d76176b9b18eefd8136f51c0188e5c57631e62
treea5c2ae0d92a73d3954e8a1699147436a26d1b3c9
parent76c729c96745bd13f83ad171f1cbd50d36893e70

document std.heap.StackFallbackAllocator


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

lib/std/heap.zig+7
......@@ -855,6 +855,9 @@ pub const FixedBufferAllocator = struct {
855855
856856pub 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.
858861pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackFallbackAllocator(size) {
859862 return StackFallbackAllocator(size){
860863 .buffer = undefined,
......@@ -863,6 +866,10 @@ pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackF
863866 };
864867}
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`.
866873pub fn StackFallbackAllocator(comptime size: usize) type {
867874 return struct {
868875 const Self = @This();