diff --git a/src/lib.zig b/src/lib.zig index 285892e5d7ee09fe9e732d4e953e90f6c0c29202..fa69f7ff0e40b06b9e3c1a7c70bf31a69ae6dfa0 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -14,7 +14,7 @@ const std = @import("std"); // ); // } -pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []const T, max: ?usize) !usize { +pub fn leven(comptime T: type, backing_alloc: std.mem.Allocator, a: []const T, b: []const T, max: ?usize) !usize { if (std.mem.eql(T, a, b)) return 0; var left = a; @@ -46,6 +46,9 @@ pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []cons var result: usize = 0; + var sfa = std.heap.stackFallback(4096, backing_alloc); + const alloc = sfa.get(); + const charCodeCache = try alloc.alloc(T, ll); defer alloc.free(charCodeCache);