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/CompatData.zig | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/CompatData.zig') diff --git a/src/CompatData.zig b/src/CompatData.zig index cf184a1..ac08048 100644 --- a/src/CompatData.zig +++ b/src/CompatData.zig @@ -3,7 +3,6 @@ const builtin = @import("builtin"); const compress = std.compress; const mem = std.mem; -allocator: mem.Allocator, nfkd: [][]u21 = undefined, const Self = @This(); @@ -17,10 +16,9 @@ pub fn init(allocator: mem.Allocator) !Self { const endian = builtin.cpu.arch.endian(); var self = Self{ - .allocator = allocator, .nfkd = try allocator.alloc([]u21, 0x110000), }; - errdefer self.deinit(); + errdefer self.deinit(allocator); @memset(self.nfkd, &.{}); @@ -37,11 +35,11 @@ pub fn init(allocator: mem.Allocator) !Self { return self; } -pub fn deinit(self: *const Self) void { +pub fn deinit(self: *const Self, allocator: mem.Allocator) void { for (self.nfkd) |slice| { - if (slice.len != 0) self.allocator.free(slice); + if (slice.len != 0) allocator.free(slice); } - self.allocator.free(self.nfkd); + allocator.free(self.nfkd); } /// Returns compatibility decomposition for `cp`. -- cgit v1.2.3