summaryrefslogtreecommitdiff
path: root/src/ScriptsData.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ScriptsData.zig')
-rw-r--r--src/ScriptsData.zig13
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
175allocator: mem.Allocator,
176s1: []u16 = undefined, 175s1: []u16 = undefined,
177s2: []u8 = undefined, 176s2: []u8 = undefined,
178s3: []u8 = undefined, 177s3: []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
211pub fn deinit(self: *const Self) void { 210pub 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
224test "script" { 223test "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}