fix: load case data early on startup instead of on demand
This is to avoid an issue with the decompressor causing heap corruption on macos. closes #169
This commit is contained in:
parent
70a33f1ebf
commit
9f2e3bf4b4
4 changed files with 19 additions and 15 deletions
|
@ -59,3 +59,13 @@ pub fn utf8_sanitize(allocator: std.mem.Allocator, input: []const u8) error{
|
|||
for (input) |byte| try writer.writeAll(try raw_byte_to_utf8(byte, &buf));
|
||||
return output.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
pub const CaseData = @import("CaseData");
|
||||
var case_data: ?CaseData = null;
|
||||
var case_data_arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
|
||||
pub fn get_case_data() *CaseData {
|
||||
if (case_data) |*cd| return cd;
|
||||
case_data = CaseData.init(case_data_arena.allocator()) catch @panic("CaseData.init");
|
||||
return &case_data.?;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue