authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-02-14 02:59:32 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-02-14 02:59:32 -08:00
logfadda0c00091c8c83d63904ddc0969d7fb8e9ae6
treed16978ae48a2c23c6c1757b0f88a15e5116ea368
parent73ac8ffff7b8bdc277711415eee9ede9d3a5e891

add a StackFallbackAllocator


1 files changed, 4 insertions(+), 1 deletions(-)

src/lib.zig+4-1
......@@ -14,7 +14,7 @@ const std = @import("std");
1414// );
1515// }
1616
17pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []const T, max: ?usize) !usize {
17pub fn leven(comptime T: type, backing_alloc: std.mem.Allocator, a: []const T, b: []const T, max: ?usize) !usize {
1818 if (std.mem.eql(T, a, b)) return 0;
1919
2020 var left = a;
......@@ -46,6 +46,9 @@ pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []cons
4646
4747 var result: usize = 0;
4848
49 var sfa = std.heap.stackFallback(4096, backing_alloc);
50 const alloc = sfa.get();
51
4952 const charCodeCache = try alloc.alloc(T, ll);
5053 defer alloc.free(charCodeCache);
5154