| ... | ... | @@ -855,6 +855,9 @@ pub const FixedBufferAllocator = struct { |
| 855 | 855 | |
| 856 | 856 | pub const ThreadSafeFixedBufferAllocator = @compileError("ThreadSafeFixedBufferAllocator has been replaced with `threadSafeAllocator` on FixedBufferAllocator"); |
| 857 | 857 | |
| 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. |
| 858 | 861 | pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackFallbackAllocator(size) { |
| 859 | 862 | return StackFallbackAllocator(size){ |
| 860 | 863 | .buffer = undefined, |
| ... | ... | @@ -863,6 +866,10 @@ pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackF |
| 863 | 866 | }; |
| 864 | 867 | } |
| 865 | 868 | |
| 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`. |
| 866 | 873 | pub fn StackFallbackAllocator(comptime size: usize) type { |
| 867 | 874 | return struct { |
| 868 | 875 | const Self = @This(); |