authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-14 00:56:14 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-14 00:56:14 -07:00
loge970ba3719c15792529200a1df3d64277b343687
tree7be4a7ed4e60481e24bd6fbe059f531c01996a5b
parent0ee7496fe5f5f05afbb00349d8cbc23c37b0a167

fix usage of std.ArrayList


9 files changed, 29 insertions(+), 29 deletions(-)

src/cmd/fetch.zig+9-9
......@@ -26,14 +26,14 @@ pub fn execute(args: [][]u8) !void {
2626 };
2727 const top_module = try common.collect_deps_deep(dir, "zig.mod", &options);
2828
29 const list = &std.ArrayList(u.Module).init(gpa);
30 try common.collect_pkgs(top_module, list);
29 var list = std.ArrayList(u.Module).init(gpa);
30 try common.collect_pkgs(top_module, &list);
3131
32 try create_depszig(dir, top_module, list);
32 try create_depszig(dir, top_module, &list);
3333
3434 if (bootstrap) return;
3535
36 try create_lockfile(list, dir);
36 try create_lockfile(&list, dir);
3737
3838 try diff_lockfile();
3939}
......@@ -92,14 +92,14 @@ pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u.
9292 try w.writeAll("};\n\n");
9393
9494 try w.writeAll("pub const package_data = struct {\n");
95 const duped = &std.ArrayList(u.Module).init(gpa);
95 var duped = std.ArrayList(u.Module).init(gpa);
9696 for (list.items) |mod| {
9797 if (mod.is_sys_lib) {
9898 continue;
9999 }
100100 try duped.append(mod);
101101 }
102 try print_pkg_data_to(w, duped, &std.ArrayList(u.Module).init(gpa));
102 try print_pkg_data_to(w, &duped, &std.ArrayList(u.Module).init(gpa));
103103 try w.writeAll("};\n\n");
104104
105105 try w.writeAll("pub const packages = ");
......@@ -149,15 +149,15 @@ fn diff_lockfile() !void {
149149 if (std.mem.startsWith(u8, line, "@@")) break;
150150 }
151151
152 const rems = &std.ArrayList(string).init(gpa);
153 const adds = &std.ArrayList(string).init(gpa);
152 var rems = std.ArrayList(string).init(gpa);
153 var adds = std.ArrayList(string).init(gpa);
154154 while (try r.readUntilDelimiterOrEofAlloc(gpa, '\n', max)) |line| {
155155 if (line[0] == ' ') continue;
156156 if (line[0] == '-') try rems.append(line[1..]);
157157 if (line[0] == '+') if (line[1] == '2') continue else try adds.append(line[1..]);
158158 }
159159
160 const changes = &std.StringHashMap(DiffChange).init(gpa);
160 var changes = std.StringHashMap(DiffChange).init(gpa);
161161
162162 var i: usize = 0;
163163 while (i < rems.items.len) {
src/cmd/sum.zig+2-2
......@@ -24,8 +24,8 @@ pub fn execute(args: [][]u8) !void {
2424 const w = f.writer();
2525
2626 //
27 const module_list = &std.ArrayList(u.Module).init(gpa);
28 try common.collect_pkgs(top_module, module_list);
27 var module_list = std.ArrayList(u.Module).init(gpa);
28 try common.collect_pkgs(top_module, &module_list);
2929
3030 for (module_list.items) |m| {
3131 if (m.clean_path.len == 0) {
src/cmd/zpm/search.zig+1-1
......@@ -19,7 +19,7 @@ pub fn execute(args: [][]u8) !void {
1919 const url = try std.mem.join(gpa, "/", &.{ zpm.server_root, "packages" });
2020 const val = try zpm.server_fetch(url);
2121
22 const arr = &std.ArrayList(zpm.Package).init(gpa);
22 var arr = std.ArrayList(zpm.Package).init(gpa);
2323 defer arr.deinit();
2424
2525 for (val.Array) |item| {
src/common.zig+3-3
......@@ -30,7 +30,7 @@ pub const CollectOptions = struct {
3030pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: *CollectOptions) !u.Module {
3131 const m = try u.ModFile.init(gpa, mpath);
3232 try options.init();
33 const moduledeps = &std.ArrayList(u.Module).init(gpa);
33 var moduledeps = std.ArrayList(u.Module).init(gpa);
3434 defer moduledeps.deinit();
3535 try std.fs.cwd().makePath(".zigmod/deps/files");
3636 if (m.root_files.len > 0) {
......@@ -56,7 +56,7 @@ pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, options: *CollectOp
5656
5757pub fn collect_deps(dir: []const u8, mpath: []const u8, options: *CollectOptions) anyerror!u.Module {
5858 const m = try u.ModFile.init(gpa, mpath);
59 const moduledeps = &std.ArrayList(u.Module).init(gpa);
59 var moduledeps = std.ArrayList(u.Module).init(gpa);
6060 defer moduledeps.deinit();
6161 if (m.files.len > 0) {
6262 try moduledeps.append(try add_files_package(m.id, m.files, m.name));
......@@ -336,7 +336,7 @@ pub fn add_files_package(pkg_name: []const u8, dirs: []const []const u8, parent_
336336}
337337
338338pub fn parse_lockfile(path: []const u8) ![]const [4][]const u8 {
339 const list = &std.ArrayList([4][]const u8).init(gpa);
339 var list = std.ArrayList([4][]const u8).init(gpa);
340340 const max = std.math.maxInt(usize);
341341 const f = try std.fs.cwd().openFile(path, .{});
342342 const r = f.reader();
src/main.zig+1-1
......@@ -53,7 +53,7 @@ pub fn main() !void {
5353 }
5454 }
5555
56 var sub_cmd_args = &std.ArrayList([]const u8).init(gpa);
56 var sub_cmd_args = std.ArrayList([]const u8).init(gpa);
5757 try sub_cmd_args.append(try std.fmt.allocPrint(gpa, "zigmod-{s}", .{args[0]}));
5858 for (args[1..]) |item| {
5959 try sub_cmd_args.append(item);
src/util/funcs.zig+3-3
......@@ -33,7 +33,7 @@ pub fn try_index(comptime T: type, array: []T, n: usize, def: T) T {
3333}
3434
3535pub fn split(in: []const u8, delim: []const u8) ![][]const u8 {
36 const list = &std.ArrayList([]const u8).init(gpa);
36 var list = std.ArrayList([]const u8).init(gpa);
3737 defer list.deinit();
3838 const iter = &std.mem.split(in, delim);
3939 while (iter.next()) |str| {
......@@ -90,7 +90,7 @@ pub fn trim_suffix(in: []const u8, suffix: []const u8) []const u8 {
9090}
9191
9292pub fn repeat(s: []const u8, times: i32) ![]const u8 {
93 const list = &std.ArrayList([]const u8).init(gpa);
93 var list = std.ArrayList([]const u8).init(gpa);
9494 var i: i32 = 0;
9595 while (i < times) : (i += 1) {
9696 try list.append(s);
......@@ -175,7 +175,7 @@ pub fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 {
175175}
176176
177177pub fn list_remove(input: [][]const u8, search: []const u8) ![][]const u8 {
178 const list = &std.ArrayList([]const u8).init(gpa);
178 var list = std.ArrayList([]const u8).init(gpa);
179179 defer list.deinit();
180180 for (input) |item| {
181181 if (!std.mem.eql(u8, item, search)) {
src/util/modfile.zig+1-1
......@@ -68,7 +68,7 @@ pub const ModFile = struct {
6868 }
6969
7070 fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: []const u8) anyerror![]u.Dep {
71 const dep_list = &std.ArrayList(u.Dep).init(alloc);
71 var dep_list = std.ArrayList(u.Dep).init(alloc);
7272 if (mapping.get(prop)) |dep_seq| {
7373 if (dep_seq == .sequence) {
7474 for (dep_seq.sequence) |item| {
src/util/module.zig+4-4
......@@ -25,7 +25,7 @@ pub const Module = struct {
2525 dep: ?u.Dep,
2626
2727 pub fn from(dep: u.Dep, dir: []const u8, options: *common.CollectOptions) !Module {
28 const moddeps = &std.ArrayList(Module).init(gpa);
28 var moddeps = std.ArrayList(Module).init(gpa);
2929 defer moddeps.deinit();
3030 for (dep.deps) |*d| {
3131 if (try common.get_module_from_dep(d, dir, dep.name, options)) |founddep| {
......@@ -54,11 +54,11 @@ pub const Module = struct {
5454 }
5555
5656 pub fn get_hash(self: Module, cdpath: []const u8) ![]const u8 {
57 const file_list_1 = &std.ArrayList([]const u8).init(gpa);
57 var file_list_1 = std.ArrayList([]const u8).init(gpa);
5858 defer file_list_1.deinit();
59 try u.file_list(try u.concat(&.{ cdpath, "/", self.clean_path }), file_list_1);
59 try u.file_list(try u.concat(&.{ cdpath, "/", self.clean_path }), &file_list_1);
6060
61 const file_list_2 = &std.ArrayList([]const u8).init(gpa);
61 var file_list_2 = std.ArrayList([]const u8).init(gpa);
6262 defer file_list_2.deinit();
6363 for (file_list_1.items) |item| {
6464 const _a = u.trim_prefix(item, cdpath);
src/util/yaml.zig+5-5
......@@ -112,7 +112,7 @@ pub const Mapping = struct {
112112 }
113113
114114 pub fn get_string_array(self: Mapping, alloc: *std.mem.Allocator, k: []const u8) ![][]const u8 {
115 const list = &std.ArrayList([]const u8).init(alloc);
115 var list = std.ArrayList([]const u8).init(alloc);
116116 defer list.deinit();
117117 if (self.get(k)) |val| {
118118 if (val == .sequence) {
......@@ -154,7 +154,7 @@ pub fn parse(alloc: *std.mem.Allocator, input: []const u8) !Document {
154154
155155 _ = c.yaml_parser_set_input_string(&parser, input.ptr, input.len);
156156
157 const all_events = &std.ArrayList(Token).init(alloc);
157 var all_events = std.ArrayList(Token).init(alloc);
158158 var event: Token = undefined;
159159 while (true) {
160160 const p = c.yaml_parser_parse(&parser, &event);
......@@ -220,7 +220,7 @@ fn parse_item(p: *Parser, start: ?Token) Error!Item {
220220}
221221
222222fn parse_stream(p: *Parser) Error!Stream {
223 const res = &std.ArrayList(Document).init(p.alloc);
223 var res = std.ArrayList(Document).init(p.alloc);
224224 defer res.deinit();
225225
226226 while (true) {
......@@ -250,7 +250,7 @@ fn parse_document(p: *Parser) Error!Document {
250250}
251251
252252fn parse_mapping(p: *Parser) Error!Mapping {
253 const res = &std.ArrayList(Key).init(p.alloc);
253 var res = std.ArrayList(Key).init(p.alloc);
254254 defer res.deinit();
255255
256256 while (true) {
......@@ -279,7 +279,7 @@ fn parse_value(p: *Parser) Error!Value {
279279}
280280
281281fn parse_sequence(p: *Parser) Error!Sequence {
282 const res = &std.ArrayList(Item).init(p.alloc);
282 var res = std.ArrayList(Item).init(p.alloc);
283283 defer res.deinit();
284284
285285 while (true) {