Skip to content

Commit e582f79

Browse files
pass allocator
No longer assume `gpa` global allocator.
1 parent fbaccfc commit e582f79

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/common.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !
208208
.fossil => {
209209
const dpath = if (d.version.len > 0) pv else p;
210210
if (!try u.does_folder_exist(dpath)) {
211-
try d.type.pull(d.path, dpath);
211+
try d.type.pull(options.alloc, d.path, dpath);
212212
} else {
213213
if (options.update) {
214-
try d.type.update(dpath, d.path);
214+
try d.type.update(options.alloc, dpath, d.path);
215215
}
216216
}
217217
if (d.version.len > 0) {
218-
u.assert((try u.run_cmd(dpath, &.{ "fossil", "checkout", d.version })) == 0, "can't fossil checkout version {s}", .{ d.version });
218+
u.assert((try u.run_cmd(options.alloc, dpath, &.{ "fossil", "checkout", d.version })) == 0, "can't fossil checkout version {s}", .{d.version});
219219
}
220220
return dpath;
221221
},

src/util/dep_type.zig

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ pub const DepType = enum {
4141
},
4242
.fossil => {
4343
try std.fs.cwd().makePath(dpath);
44-
u.assert((try u.run_cmd(dpath, &.{ "fossil", "open", rpath})) == 0, "fossil open {s} failed", .{rpath});
45-
}
44+
u.assert((try u.run_cmd(alloc, dpath, &.{ "fossil", "open", rpath })) == 0, "fossil open {s} failed", .{rpath});
45+
},
4646
}
4747
}
4848

@@ -64,8 +64,8 @@ pub const DepType = enum {
6464
//
6565
},
6666
.fossil => {
67-
u.assert((try u.run_cmd(dpath, &.{ "fossil", "pull" })) == 0, "fossil pull failed", .{});
68-
u.assert((try u.run_cmd(dpath, &.{ "fossil", "update" })) == 0, "fossil update failed", .{});
67+
u.assert((try u.run_cmd(alloc, dpath, &.{ "fossil", "pull" })) == 0, "fossil pull failed", .{});
68+
u.assert((try u.run_cmd(alloc, dpath, &.{ "fossil", "update" })) == 0, "fossil update failed", .{});
6969
},
7070
}
7171
}
@@ -80,7 +80,7 @@ pub const DepType = enum {
8080
.git => try std.fmt.allocPrint(alloc, "commit-{s}", .{(try u.git_rev_HEAD(alloc, mdir))}),
8181
.hg => "",
8282
.http => "",
83-
.fossil => getFossilCheckout(mpath),
83+
.fossil => getFossilCheckout(alloc, mpath),
8484
};
8585
}
8686

@@ -92,6 +92,7 @@ pub const DepType = enum {
9292
.git => false,
9393
.hg => false,
9494
.http => false,
95+
.fossil => false,
9596
};
9697
}
9798

@@ -102,6 +103,7 @@ pub const DepType = enum {
102103
git: Git,
103104
hg: void,
104105
http: void,
106+
fossil: void,
105107

106108
pub const Git = enum {
107109
branch,
@@ -119,20 +121,18 @@ pub const DepType = enum {
119121
};
120122
};
121123

122-
123-
fn getFossilCheckout(mpath: []const u8) ![]const u8 {
124-
const result = try u.run_cmd_raw(mpath, &.{"fossil", "status"});
125-
gpa.free(result.stderr);
126-
defer gpa.free(result.stdout);
124+
fn getFossilCheckout(alloc: std.mem.Allocator, mpath: []const u8) ![]const u8 {
125+
const result = try u.run_cmd_raw(alloc, mpath, &.{ "fossil", "status" });
126+
alloc.free(result.stderr);
127+
defer alloc.free(result.stdout);
127128

128129
var iter = std.mem.tokenize(u8, result.stdout, " \n");
129130
while (iter.next()) |tk| {
130131
if (std.mem.eql(u8, tk, "checkout:")) {
131132
const co = iter.next() orelse return "";
132-
return try gpa.dupe(u8, co);
133+
return try alloc.dupe(u8, co);
133134
}
134135
}
135136

136137
return "";
137138
}
138-

0 commit comments

Comments
 (0)