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/HangulData.zig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/HangulData.zig') diff --git a/src/HangulData.zig b/src/HangulData.zig index 048841d..4bccbe6 100644 --- a/src/HangulData.zig +++ b/src/HangulData.zig @@ -13,7 +13,6 @@ pub const Syllable = enum { T, }; -allocator: mem.Allocator, s1: []u16 = undefined, s2: []u3 = undefined, @@ -27,7 +26,7 @@ pub fn init(allocator: mem.Allocator) !Self { var reader = in_decomp.reader(); const endian = builtin.cpu.arch.endian(); - var self = Self{ .allocator = allocator }; + var self = Self{}; const stage_1_len: u16 = try reader.readInt(u16, endian); self.s1 = try allocator.alloc(u16, stage_1_len); @@ -42,9 +41,9 @@ pub fn init(allocator: mem.Allocator) !Self { return self; } -pub fn deinit(self: *const Self) void { - self.allocator.free(self.s1); - self.allocator.free(self.s2); +pub fn deinit(self: *const Self, allocator: mem.Allocator) void { + allocator.free(self.s1); + allocator.free(self.s2); } /// Returns the Hangul syllable type for `cp`. -- cgit v1.2.3