diff options
Diffstat (limited to 'src/CompatData.zig')
| -rw-r--r-- | src/CompatData.zig | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/CompatData.zig b/src/CompatData.zig index cf184a1..ac08048 100644 --- a/src/CompatData.zig +++ b/src/CompatData.zig | |||
| @@ -3,7 +3,6 @@ const builtin = @import("builtin"); | |||
| 3 | const compress = std.compress; | 3 | const compress = std.compress; |
| 4 | const mem = std.mem; | 4 | const mem = std.mem; |
| 5 | 5 | ||
| 6 | allocator: mem.Allocator, | ||
| 7 | nfkd: [][]u21 = undefined, | 6 | nfkd: [][]u21 = undefined, |
| 8 | 7 | ||
| 9 | const Self = @This(); | 8 | const Self = @This(); |
| @@ -17,10 +16,9 @@ pub fn init(allocator: mem.Allocator) !Self { | |||
| 17 | 16 | ||
| 18 | const endian = builtin.cpu.arch.endian(); | 17 | const endian = builtin.cpu.arch.endian(); |
| 19 | var self = Self{ | 18 | var self = Self{ |
| 20 | .allocator = allocator, | ||
| 21 | .nfkd = try allocator.alloc([]u21, 0x110000), | 19 | .nfkd = try allocator.alloc([]u21, 0x110000), |
| 22 | }; | 20 | }; |
| 23 | errdefer self.deinit(); | 21 | errdefer self.deinit(allocator); |
| 24 | 22 | ||
| 25 | @memset(self.nfkd, &.{}); | 23 | @memset(self.nfkd, &.{}); |
| 26 | 24 | ||
| @@ -37,11 +35,11 @@ pub fn init(allocator: mem.Allocator) !Self { | |||
| 37 | return self; | 35 | return self; |
| 38 | } | 36 | } |
| 39 | 37 | ||
| 40 | pub fn deinit(self: *const Self) void { | 38 | pub fn deinit(self: *const Self, allocator: mem.Allocator) void { |
| 41 | for (self.nfkd) |slice| { | 39 | for (self.nfkd) |slice| { |
| 42 | if (slice.len != 0) self.allocator.free(slice); | 40 | if (slice.len != 0) allocator.free(slice); |
| 43 | } | 41 | } |
| 44 | self.allocator.free(self.nfkd); | 42 | allocator.free(self.nfkd); |
| 45 | } | 43 | } |
| 46 | 44 | ||
| 47 | /// Returns compatibility decomposition for `cp`. | 45 | /// Returns compatibility decomposition for `cp`. |