diff options
Diffstat (limited to 'src/WidthData.zig')
| -rw-r--r-- | src/WidthData.zig | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/WidthData.zig b/src/WidthData.zig index d77879e..4a49c80 100644 --- a/src/WidthData.zig +++ b/src/WidthData.zig | |||
| @@ -6,7 +6,6 @@ const testing = std.testing; | |||
| 6 | 6 | ||
| 7 | const GraphemeData = @import("GraphemeData"); | 7 | const GraphemeData = @import("GraphemeData"); |
| 8 | 8 | ||
| 9 | allocator: mem.Allocator, | ||
| 10 | g_data: GraphemeData, | 9 | g_data: GraphemeData, |
| 11 | s1: []u16 = undefined, | 10 | s1: []u16 = undefined, |
| 12 | s2: []i4 = undefined, | 11 | s2: []i4 = undefined, |
| @@ -23,10 +22,9 @@ pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self { | |||
| 23 | const endian = builtin.cpu.arch.endian(); | 22 | const endian = builtin.cpu.arch.endian(); |
| 24 | 23 | ||
| 25 | var self = Self{ | 24 | var self = Self{ |
| 26 | .allocator = allocator, | ||
| 27 | .g_data = try GraphemeData.init(allocator), | 25 | .g_data = try GraphemeData.init(allocator), |
| 28 | }; | 26 | }; |
| 29 | errdefer self.g_data.deinit(); | 27 | errdefer self.g_data.deinit(allocator); |
| 30 | 28 | ||
| 31 | const stage_1_len: u16 = reader.readInt(u16, endian) catch unreachable; | 29 | const stage_1_len: u16 = reader.readInt(u16, endian) catch unreachable; |
| 32 | self.s1 = try allocator.alloc(u16, stage_1_len); | 30 | self.s1 = try allocator.alloc(u16, stage_1_len); |
| @@ -41,10 +39,10 @@ pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self { | |||
| 41 | return self; | 39 | return self; |
| 42 | } | 40 | } |
| 43 | 41 | ||
| 44 | pub fn deinit(self: *const Self) void { | 42 | pub fn deinit(self: *const Self, allocator: mem.Allocator) void { |
| 45 | self.allocator.free(self.s1); | 43 | allocator.free(self.s1); |
| 46 | self.allocator.free(self.s2); | 44 | allocator.free(self.s2); |
| 47 | self.g_data.deinit(); | 45 | self.g_data.deinit(allocator); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | /// codePointWidth returns the number of cells `cp` requires when rendered | 48 | /// codePointWidth returns the number of cells `cp` requires when rendered |