summaryrefslogtreecommitdiff
path: root/src/GraphemeData.zig
diff options
context:
space:
mode:
authorGravatar lch3612025-03-25 00:29:52 +0300
committerGravatar Sam Atman2025-04-29 12:30:55 -0400
commit2f44fdebca57d9eabb682e05d04189d0600b8664 (patch)
tree617e7d4be89c1a965848dbc7f9b5f2a273faa9d7 /src/GraphemeData.zig
parentBump copyright year, isolate iterator tests (diff)
downloadzg-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/GraphemeData.zig')
-rw-r--r--src/GraphemeData.zig11
1 files changed, 5 insertions, 6 deletions
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 {
30 ZWJ, 30 ZWJ,
31}; 31};
32 32
33allocator: mem.Allocator,
34s1: []u16 = undefined, 33s1: []u16 = undefined,
35s2: []u16 = undefined, 34s2: []u16 = undefined,
36s3: []u8 = undefined, 35s3: []u8 = undefined,
@@ -46,7 +45,7 @@ pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self {
46 45
47 const endian = builtin.cpu.arch.endian(); 46 const endian = builtin.cpu.arch.endian();
48 47
49 var self = Self{ .allocator = allocator }; 48 var self = Self{};
50 49
51 const s1_len: u16 = reader.readInt(u16, endian) catch unreachable; 50 const s1_len: u16 = reader.readInt(u16, endian) catch unreachable;
52 self.s1 = try allocator.alloc(u16, s1_len); 51 self.s1 = try allocator.alloc(u16, s1_len);
@@ -66,10 +65,10 @@ pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self {
66 return self; 65 return self;
67} 66}
68 67
69pub fn deinit(self: *const Self) void { 68pub fn deinit(self: *const Self, allocator: mem.Allocator) void {
70 self.allocator.free(self.s1); 69 allocator.free(self.s1);
71 self.allocator.free(self.s2); 70 allocator.free(self.s2);
72 self.allocator.free(self.s3); 71 allocator.free(self.s3);
73} 72}
74 73
75/// Lookup the grapheme break property for a code point. 74/// Lookup the grapheme break property for a code point.