From 2f44fdebca57d9eabb682e05d04189d0600b8664 Mon Sep 17 00:00:00 2001 From: lch361 Date: Tue, 25 Mar 2025 00:29:52 +0300 Subject: All the std.mem.Allocators that were stored just for init and deinit methods were removed, mem.Allocators were added to deinit as arguments. --- src/WidthData.zig | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/WidthData.zig') 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; const GraphemeData = @import("GraphemeData"); -allocator: mem.Allocator, g_data: GraphemeData, s1: []u16 = undefined, s2: []i4 = undefined, @@ -23,10 +22,9 @@ pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self { const endian = builtin.cpu.arch.endian(); var self = Self{ - .allocator = allocator, .g_data = try GraphemeData.init(allocator), }; - errdefer self.g_data.deinit(); + errdefer self.g_data.deinit(allocator); const stage_1_len: u16 = reader.readInt(u16, endian) catch unreachable; self.s1 = try allocator.alloc(u16, stage_1_len); @@ -41,10 +39,10 @@ pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self { return self; } -pub fn deinit(self: *const Self) void { - self.allocator.free(self.s1); - self.allocator.free(self.s2); - self.g_data.deinit(); +pub fn deinit(self: *const Self, allocator: mem.Allocator) void { + allocator.free(self.s1); + allocator.free(self.s2); + self.g_data.deinit(allocator); } /// codePointWidth returns the number of cells `cp` requires when rendered -- cgit v1.2.3