diff options
Diffstat (limited to 'src/GeneralCategories.zig')
| -rw-r--r-- | src/GeneralCategories.zig | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/src/GeneralCategories.zig b/src/GeneralCategories.zig index 3e76d82..8c1b6a3 100644 --- a/src/GeneralCategories.zig +++ b/src/GeneralCategories.zig | |||
| @@ -47,15 +47,6 @@ pub fn init(allocator: Allocator) Allocator.Error!GeneralCategories { | |||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | pub fn setup(gencat: *GeneralCategories, allocator: Allocator) Allocator.Error!void { | 49 | pub fn setup(gencat: *GeneralCategories, allocator: Allocator) Allocator.Error!void { |
| 50 | gencat.setupInner(allocator) catch |err| { | ||
| 51 | switch (err) { | ||
| 52 | error.OutOfMemory => |e| return e, | ||
| 53 | else => unreachable, | ||
| 54 | } | ||
| 55 | }; | ||
| 56 | } | ||
| 57 | |||
| 58 | inline fn setupInner(gencat: *GeneralCategories, allocator: Allocator) !void { | ||
| 59 | const decompressor = compress.flate.inflate.decompressor; | 50 | const decompressor = compress.flate.inflate.decompressor; |
| 60 | const in_bytes = @embedFile("gencat"); | 51 | const in_bytes = @embedFile("gencat"); |
| 61 | var in_fbs = std.io.fixedBufferStream(in_bytes); | 52 | var in_fbs = std.io.fixedBufferStream(in_bytes); |
| @@ -67,7 +58,7 @@ inline fn setupInner(gencat: *GeneralCategories, allocator: Allocator) !void { | |||
| 67 | const s1_len: u16 = reader.readInt(u16, endian) catch unreachable; | 58 | const s1_len: u16 = reader.readInt(u16, endian) catch unreachable; |
| 68 | gencat.s1 = try allocator.alloc(u16, s1_len); | 59 | gencat.s1 = try allocator.alloc(u16, s1_len); |
| 69 | errdefer allocator.free(gencat.s1); | 60 | errdefer allocator.free(gencat.s1); |
| 70 | for (0..s1_len) |i| gencat.s1[i] = try reader.readInt(u16, endian); | 61 | for (0..s1_len) |i| gencat.s1[i] = reader.readInt(u16, endian) catch unreachable; |
| 71 | 62 | ||
| 72 | const s2_len: u16 = reader.readInt(u16, endian) catch unreachable; | 63 | const s2_len: u16 = reader.readInt(u16, endian) catch unreachable; |
| 73 | gencat.s2 = try allocator.alloc(u5, s2_len); | 64 | gencat.s2 = try allocator.alloc(u5, s2_len); |