authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 11:47:43 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 11:47:43 -07:00
log928e8883003aa02de7f66d29fee86f0bcdd8e090
treeba211604f136859f49ad929378874937a1ba6ecf
parent3db48d1a413cc05116643dee257649a1c0a7aa3c

use errdefer for std.ArrayList deinit


4 files changed, 7 insertions(+), 7 deletions(-)

src/common.zig+2-2
...@@ -29,7 +29,7 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO...@@ -29,7 +29,7 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO
29 const m = try zigmod.ModFile.from_dir(options.alloc, mdir);29 const m = try zigmod.ModFile.from_dir(options.alloc, mdir);
30 try options.init();30 try options.init();
31 var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc);31 var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc);
32 defer moduledeps.deinit();32 errdefer moduledeps.deinit();
33 if (m.root_files.len > 0) {33 if (m.root_files.len > 0) {
34 try moduledeps.append(try add_files_package(options.alloc, cachepath, "root", mdir, m.root_files));34 try moduledeps.append(try add_files_package(options.alloc, cachepath, "root", mdir, m.root_files));
35 }35 }
...@@ -63,7 +63,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type,...@@ -63,7 +63,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type,
6363
64 const m = try zigmod.ModFile.from_dir(options.alloc, mdir);64 const m = try zigmod.ModFile.from_dir(options.alloc, mdir);
65 var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc);65 var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc);
66 defer moduledeps.deinit();66 errdefer moduledeps.deinit();
67 if (m.files.len > 0) {67 if (m.files.len > 0) {
68 try moduledeps.append(try add_files_package(options.alloc, cachepath, m.id, mdir, m.files));68 try moduledeps.append(try add_files_package(options.alloc, cachepath, m.id, mdir, m.files));
69 }69 }
src/util/funcs.zig+2-2
...@@ -36,7 +36,7 @@ pub fn try_index(comptime T: type, array: []T, n: usize, def: T) T {...@@ -36,7 +36,7 @@ pub fn try_index(comptime T: type, array: []T, n: usize, def: T) T {
3636
37pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {37pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {
38 var list = std.ArrayList(string).init(alloc);38 var list = std.ArrayList(string).init(alloc);
39 defer list.deinit();39 errdefer list.deinit();
4040
41 var iter = std.mem.split(u8, in, delim);41 var iter = std.mem.split(u8, in, delim);
42 while (iter.next()) |str| {42 while (iter.next()) |str| {
...@@ -122,7 +122,7 @@ pub fn run_cmd(alloc: std.mem.Allocator, dir: ?string, args: []const string) !u3...@@ -122,7 +122,7 @@ pub fn run_cmd(alloc: std.mem.Allocator, dir: ?string, args: []const string) !u3
122122
123pub fn list_remove(alloc: std.mem.Allocator, input: []string, search: string) ![]string {123pub fn list_remove(alloc: std.mem.Allocator, input: []string, search: string) ![]string {
124 var list = std.ArrayList(string).init(alloc);124 var list = std.ArrayList(string).init(alloc);
125 defer list.deinit();125 errdefer list.deinit();
126 for (input) |item| {126 for (input) |item| {
127 if (!std.mem.eql(u8, item, search)) {127 if (!std.mem.eql(u8, item, search)) {
128 try list.append(item);128 try list.append(item);
src/util/modfile.zig+1-1
...@@ -81,7 +81,7 @@ pub const ModFile = struct {...@@ -81,7 +81,7 @@ pub const ModFile = struct {
8181
82 fn dep_list_by_name(alloc: std.mem.Allocator, mapping: yaml.Mapping, props: []const string, for_build: bool) std.mem.Allocator.Error![]zigmod.Dep {82 fn dep_list_by_name(alloc: std.mem.Allocator, mapping: yaml.Mapping, props: []const string, for_build: bool) std.mem.Allocator.Error![]zigmod.Dep {
83 var dep_list = std.ArrayList(zigmod.Dep).init(alloc);83 var dep_list = std.ArrayList(zigmod.Dep).init(alloc);
84 defer dep_list.deinit();84 errdefer dep_list.deinit();
8585
86 for (props) |prop| {86 for (props) |prop| {
87 if (mapping.get(prop)) |dep_seq| {87 if (mapping.get(prop)) |dep_seq| {
src/util/module.zig+2-2
...@@ -31,7 +31,7 @@ pub const Module = struct {...@@ -31,7 +31,7 @@ pub const Module = struct {
3131
32 pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, modpath: string, options: *common.CollectOptions) !Module {32 pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, modpath: string, options: *common.CollectOptions) !Module {
33 var moddeps = std.ArrayList(Module).init(alloc);33 var moddeps = std.ArrayList(Module).init(alloc);
34 defer moddeps.deinit();34 errdefer moddeps.deinit();
3535
36 for (dep.deps) |*d| {36 for (dep.deps) |*d| {
37 if (try common.get_module_from_dep(d, modpath, options)) |founddep| {37 if (try common.get_module_from_dep(d, modpath, options)) |founddep| {
...@@ -66,7 +66,7 @@ pub const Module = struct {...@@ -66,7 +66,7 @@ pub const Module = struct {
66 const file_list_1 = try u.file_list(alloc, try std.mem.concat(alloc, u8, &.{ cdpath, "/", self.clean_path }));66 const file_list_1 = try u.file_list(alloc, try std.mem.concat(alloc, u8, &.{ cdpath, "/", self.clean_path }));
6767
68 var file_list_2 = std.ArrayList(string).init(alloc);68 var file_list_2 = std.ArrayList(string).init(alloc);
69 defer file_list_2.deinit();69 errdefer file_list_2.deinit();
70 for (file_list_1) |item| {70 for (file_list_1) |item| {
71 const _a = extras.trimPrefix(item, cdpath);71 const _a = extras.trimPrefix(item, cdpath);
72 const _b = extras.trimPrefix(_a, self.clean_path);72 const _b = extras.trimPrefix(_a, self.clean_path);