From f9ed63ba65289f3e0ef5b0d8609d09996780c767 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 28 Oct 2021 03:41:03 -0700 Subject: [PATCH] remove global allocator from u.file_list --- src/util/funcs.zig | 8 ++++---- src/util/module.zig | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/funcs.zig b/src/util/funcs.zig index af10c540fc73dc3998b9f3c8bd24e4abbefdc059..766e709648275e643805de4a9e64a03908fd4160 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -114,19 +114,19 @@ pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool return false; } -pub fn file_list(dpath: string) ![]const string { - var list = std.ArrayList(string).init(gpa); +pub fn file_list(alloc: *std.mem.Allocator, dpath: string) ![]const string { + var list = std.ArrayList(string).init(alloc); defer list.deinit(); const dir = try std.fs.cwd().openDir(dpath, .{ .iterate = true }); - var walk = try dir.walk(gpa); + var walk = try dir.walk(alloc); defer walk.deinit(); while (true) { if (try walk.next()) |entry| { if (entry.kind != .File) { continue; } - try list.append(try gpa.dupe(u8, entry.path)); + try list.append(try alloc.dupe(u8, entry.path)); } else { break; } diff --git a/src/util/module.zig b/src/util/module.zig index 053ca36798b14dcc2a4e1f341b7aa38d88adcfdb..99dbbde8bbd25d17890805ee977a1484552b279b 100644 --- a/src/util/module.zig +++ b/src/util/module.zig @@ -58,7 +58,7 @@ pub const Module = struct { } pub fn get_hash(self: Module, cdpath: string) !string { - const file_list_1 = try u.file_list(try std.mem.concat(self.alloc, u8, &.{ cdpath, "/", self.clean_path })); + const file_list_1 = try u.file_list(self.alloc, try std.mem.concat(self.alloc, u8, &.{ cdpath, "/", self.clean_path })); var file_list_2 = std.ArrayList(string).init(self.alloc); defer file_list_2.deinit(); -- 2.54.0