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/GraphemeData.zig | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/GraphemeData.zig') diff --git a/src/GraphemeData.zig b/src/GraphemeData.zig index de98bde..6d3174d 100644 --- a/src/GraphemeData.zig +++ b/src/GraphemeData.zig @@ -30,7 +30,6 @@ pub const Gbp = enum { ZWJ, }; -allocator: mem.Allocator, s1: []u16 = undefined, s2: []u16 = undefined, s3: []u8 = undefined, @@ -46,7 +45,7 @@ pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self { const endian = builtin.cpu.arch.endian(); - var self = Self{ .allocator = allocator }; + var self = Self{}; const s1_len: u16 = reader.readInt(u16, endian) catch unreachable; self.s1 = try allocator.alloc(u16, s1_len); @@ -66,10 +65,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.allocator.free(self.s3); +pub fn deinit(self: *const Self, allocator: mem.Allocator) void { + allocator.free(self.s1); + allocator.free(self.s2); + allocator.free(self.s3); } /// Lookup the grapheme break property for a code point. -- cgit v1.2.3