summaryrefslogtreecommitdiff
path: root/src/WidthData.zig
diff options
context:
space:
mode:
authorGravatar lch3612025-03-25 00:29:52 +0300
committerGravatar Sam Atman2025-04-29 12:30:55 -0400
commit2f44fdebca57d9eabb682e05d04189d0600b8664 (patch)
tree617e7d4be89c1a965848dbc7f9b5f2a273faa9d7 /src/WidthData.zig
parentBump copyright year, isolate iterator tests (diff)
downloadzg-2f44fdebca57d9eabb682e05d04189d0600b8664.tar.gz
zg-2f44fdebca57d9eabb682e05d04189d0600b8664.tar.xz
zg-2f44fdebca57d9eabb682e05d04189d0600b8664.zip
All the std.mem.Allocators that were stored just for init and deinit
methods were removed, mem.Allocators were added to deinit as arguments.
Diffstat (limited to 'src/WidthData.zig')
-rw-r--r--src/WidthData.zig12
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
7const GraphemeData = @import("GraphemeData"); 7const GraphemeData = @import("GraphemeData");
8 8
9allocator: mem.Allocator,
10g_data: GraphemeData, 9g_data: GraphemeData,
11s1: []u16 = undefined, 10s1: []u16 = undefined,
12s2: []i4 = undefined, 11s2: []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
44pub fn deinit(self: *const Self) void { 42pub 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