diff options
| author | 2025-03-25 00:29:52 +0300 | |
|---|---|---|
| committer | 2025-04-29 12:30:55 -0400 | |
| commit | 2f44fdebca57d9eabb682e05d04189d0600b8664 (patch) | |
| tree | 617e7d4be89c1a965848dbc7f9b5f2a273faa9d7 /src/ScriptsData.zig | |
| parent | Bump copyright year, isolate iterator tests (diff) | |
| download | zg-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/ScriptsData.zig')
| -rw-r--r-- | src/ScriptsData.zig | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/ScriptsData.zig b/src/ScriptsData.zig index 415ce2d..4ad8549 100644 --- a/src/ScriptsData.zig +++ b/src/ScriptsData.zig | |||
| @@ -172,7 +172,6 @@ pub const Script = enum { | |||
| 172 | Zanabazar_Square, | 172 | Zanabazar_Square, |
| 173 | }; | 173 | }; |
| 174 | 174 | ||
| 175 | allocator: mem.Allocator, | ||
| 176 | s1: []u16 = undefined, | 175 | s1: []u16 = undefined, |
| 177 | s2: []u8 = undefined, | 176 | s2: []u8 = undefined, |
| 178 | s3: []u8 = undefined, | 177 | s3: []u8 = undefined, |
| @@ -188,7 +187,7 @@ pub fn init(allocator: mem.Allocator) !Self { | |||
| 188 | 187 | ||
| 189 | const endian = builtin.cpu.arch.endian(); | 188 | const endian = builtin.cpu.arch.endian(); |
| 190 | 189 | ||
| 191 | var self = Self{ .allocator = allocator }; | 190 | var self = Self{}; |
| 192 | 191 | ||
| 193 | const s1_len: u16 = try reader.readInt(u16, endian); | 192 | const s1_len: u16 = try reader.readInt(u16, endian); |
| 194 | self.s1 = try allocator.alloc(u16, s1_len); | 193 | self.s1 = try allocator.alloc(u16, s1_len); |
| @@ -208,10 +207,10 @@ pub fn init(allocator: mem.Allocator) !Self { | |||
| 208 | return self; | 207 | return self; |
| 209 | } | 208 | } |
| 210 | 209 | ||
| 211 | pub fn deinit(self: *const Self) void { | 210 | pub fn deinit(self: *const Self, allocator: mem.Allocator) void { |
| 212 | self.allocator.free(self.s1); | 211 | allocator.free(self.s1); |
| 213 | self.allocator.free(self.s2); | 212 | allocator.free(self.s2); |
| 214 | self.allocator.free(self.s3); | 213 | allocator.free(self.s3); |
| 215 | } | 214 | } |
| 216 | 215 | ||
| 217 | /// Lookup the Script type for `cp`. | 216 | /// Lookup the Script type for `cp`. |
| @@ -223,6 +222,6 @@ pub fn script(self: Self, cp: u21) ?Script { | |||
| 223 | 222 | ||
| 224 | test "script" { | 223 | test "script" { |
| 225 | const self = try init(std.testing.allocator); | 224 | const self = try init(std.testing.allocator); |
| 226 | defer self.deinit(); | 225 | defer self.deinit(std.testing.allocator); |
| 227 | try testing.expectEqual(Script.Latin, self.script('A').?); | 226 | try testing.expectEqual(Script.Latin, self.script('A').?); |
| 228 | } | 227 | } |