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:
CJ van den Berg 2025-02-12 18:09:14 +01:00
parent 70a33f1ebf
commit 9f2e3bf4b4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 19 additions and 15 deletions

View file

@ -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.?;
}