diff --git a/src/cmd/sum.zig b/src/cmd/sum.zig index a45df8a2a51a073a070224434a8cf8158b6579bd..8ad66ab5e7f71ced749f23003c3abd84124b3499 100644 --- a/src/cmd/sum.zig +++ b/src/cmd/sum.zig @@ -37,7 +37,7 @@ pub fn execute(args: [][]u8) !void { continue; } if (m.is_sys_lib or m.is_framework) continue; - const hash = try m.get_hash(cachepath); + const hash = try m.get_hash(gpa, cachepath); try w.print("{s} {s}\n", .{ hash, m.clean_path }); } } diff --git a/src/common.zig b/src/common.zig index b8f2e84fc48293d19f10856b983324f27be8bdb1..eebdf3a0b2f3f20c7ca8f99d673ca7ec4cf6ac09 100644 --- a/src/common.zig +++ b/src/common.zig @@ -48,7 +48,6 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO } } return zigmod.Module{ - .alloc = options.alloc, .is_sys_lib = false, .is_framework = false, .id = "root", @@ -78,7 +77,6 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption } } return zigmod.Module{ - .alloc = options.alloc, .is_sys_lib = false, .is_framework = false, .id = m.id, @@ -231,7 +229,6 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO switch (d.type) { .system_lib, .framework => { return zigmod.Module{ - .alloc = options.alloc, .is_sys_lib = d.type == .system_lib, .is_framework = d.type == .framework, .id = try u.do_hash(options.alloc, std.crypto.hash.sha3.Sha3_384, d.path), diff --git a/src/util/module.zig b/src/util/module.zig index 9f5401fe8e17a225f864bd9711bfe6983b6e4403..7239e848da6ec13dd2660bcf4e8c0dd7c7e2080d 100644 --- a/src/util/module.zig +++ b/src/util/module.zig @@ -11,7 +11,6 @@ const common = @import("./../common.zig"); // pub const Module = struct { - alloc: std.mem.Allocator, is_sys_lib: bool, is_framework: bool, id: string, @@ -40,7 +39,6 @@ pub const Module = struct { } } return Module{ - .alloc = alloc, .is_sys_lib = false, .is_framework = false, .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48), @@ -65,10 +63,10 @@ pub const Module = struct { return std.mem.eql(u8, self.id, another.id); } - pub fn get_hash(self: Module, cdpath: string) !string { - const file_list_1 = try u.file_list(self.alloc, try std.mem.concat(self.alloc, u8, &.{ cdpath, "/", self.clean_path })); + pub fn get_hash(self: Module, alloc: std.mem.Allocator, cdpath: string) !string { + const file_list_1 = try u.file_list(alloc, try std.mem.concat(alloc, u8, &.{ cdpath, "/", self.clean_path })); - var file_list_2 = std.ArrayList(string).init(self.alloc); + var file_list_2 = std.ArrayList(string).init(alloc); defer file_list_2.deinit(); for (file_list_1) |item| { const _a = u.trim_prefix(item, cdpath); @@ -86,15 +84,15 @@ pub const Module = struct { const h = &std.crypto.hash.Blake3.init(.{}); for (file_list_2.items) |item| { - const abs_path = try std.fs.path.join(self.alloc, &.{ cdpath, self.clean_path, item }); + const abs_path = try std.fs.path.join(alloc, &.{ cdpath, self.clean_path, item }); const file = try std.fs.cwd().openFile(abs_path, .{}); defer file.close(); - const input = try file.reader().readAllAlloc(self.alloc, u.mb * 100); + const input = try file.reader().readAllAlloc(alloc, u.mb * 100); h.update(input); } var out: [32]u8 = undefined; h.final(&out); - const hex = try std.fmt.allocPrint(self.alloc, "blake3-{x}", .{std.fmt.fmtSliceHexLower(out[0..])}); + const hex = try std.fmt.allocPrint(alloc, "blake3-{x}", .{std.fmt.fmtSliceHexLower(out[0..])}); return hex; }