summaryrefslogtreecommitdiff
path: root/src/Normalize.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/Normalize.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/Normalize.zig')
-rw-r--r--src/Normalize.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Normalize.zig b/src/Normalize.zig
index 1e9878b..7b87406 100644
--- a/src/Normalize.zig
+++ b/src/Normalize.zig
@@ -221,11 +221,11 @@ test "decompose" {
221 221
222/// Returned from various functions in this namespace. Remember to call `deinit` to free any allocated memory. 222/// Returned from various functions in this namespace. Remember to call `deinit` to free any allocated memory.
223pub const Result = struct { 223pub const Result = struct {
224 allocator: ?mem.Allocator = null, 224 allocated: bool = false,
225 slice: []const u8, 225 slice: []const u8,
226 226
227 pub fn deinit(self: *const Result) void { 227 pub fn deinit(self: *const Result, allocator: mem.Allocator) void {
228 if (self.allocator) |allocator| allocator.free(self.slice); 228 if (self.allocated) allocator.free(self.slice);
229 } 229 }
230}; 230};
231 231
@@ -291,7 +291,7 @@ fn nfxd(self: Self, allocator: mem.Allocator, str: []const u8, form: Form) mem.A
291 try dstr_list.appendSlice(buf[0..len]); 291 try dstr_list.appendSlice(buf[0..len]);
292 } 292 }
293 293
294 return Result{ .allocator = allocator, .slice = try dstr_list.toOwnedSlice() }; 294 return Result{ .allocated = true, .slice = try dstr_list.toOwnedSlice() };
295} 295}
296 296
297test "nfd ASCII / no-alloc" { 297test "nfd ASCII / no-alloc" {
@@ -528,7 +528,7 @@ fn nfxc(self: Self, allocator: mem.Allocator, str: []const u8, form: Form) mem.A
528 try cstr_list.appendSlice(buf[0..len]); 528 try cstr_list.appendSlice(buf[0..len]);
529 } 529 }
530 530
531 return Result{ .allocator = allocator, .slice = try cstr_list.toOwnedSlice() }; 531 return Result{ .allocated = true, .slice = try cstr_list.toOwnedSlice() };
532 } 532 }
533 } 533 }
534} 534}