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
2929 const m = try zigmod.ModFile.from_dir(options.alloc, mdir);
3030 try options.init();
3131 var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc);
32 defer moduledeps.deinit();
32 errdefer moduledeps.deinit();
3333 if (m.root_files.len > 0) {
3434 try moduledeps.append(try add_files_package(options.alloc, cachepath, "root", mdir, m.root_files));
3535 }
......@@ -63,7 +63,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type,
6363
6464 const m = try zigmod.ModFile.from_dir(options.alloc, mdir);
6565 var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc);
66 defer moduledeps.deinit();
66 errdefer moduledeps.deinit();
6767 if (m.files.len > 0) {
6868 try moduledeps.append(try add_files_package(options.alloc, cachepath, m.id, mdir, m.files));
6969 }
src/util/funcs.zig+2-2
......@@ -36,7 +36,7 @@ pub fn try_index(comptime T: type, array: []T, n: usize, def: T) T {
3636
3737pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {
3838 var list = std.ArrayList(string).init(alloc);
39 defer list.deinit();
39 errdefer list.deinit();
4040
4141 var iter = std.mem.split(u8, in, delim);
4242 while (iter.next()) |str| {
......@@ -122,7 +122,7 @@ pub fn run_cmd(alloc: std.mem.Allocator, dir: ?string, args: []const string) !u3
122122
123123pub fn list_remove(alloc: std.mem.Allocator, input: []string, search: string) ![]string {
124124 var list = std.ArrayList(string).init(alloc);
125 defer list.deinit();
125 errdefer list.deinit();
126126 for (input) |item| {
127127 if (!std.mem.eql(u8, item, search)) {
128128 try list.append(item);
src/util/modfile.zig+1-1
......@@ -81,7 +81,7 @@ pub const ModFile = struct {
8181
8282 fn dep_list_by_name(alloc: std.mem.Allocator, mapping: yaml.Mapping, props: []const string, for_build: bool) std.mem.Allocator.Error![]zigmod.Dep {
8383 var dep_list = std.ArrayList(zigmod.Dep).init(alloc);
84 defer dep_list.deinit();
84 errdefer dep_list.deinit();
8585
8686 for (props) |prop| {
8787 if (mapping.get(prop)) |dep_seq| {
src/util/module.zig+2-2
......@@ -31,7 +31,7 @@ pub const Module = struct {
3131
3232 pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, modpath: string, options: *common.CollectOptions) !Module {
3333 var moddeps = std.ArrayList(Module).init(alloc);
34 defer moddeps.deinit();
34 errdefer moddeps.deinit();
3535
3636 for (dep.deps) |*d| {
3737 if (try common.get_module_from_dep(d, modpath, options)) |founddep| {
......@@ -66,7 +66,7 @@ pub const Module = struct {
6666 const file_list_1 = try u.file_list(alloc, try std.mem.concat(alloc, u8, &.{ cdpath, "/", self.clean_path }));
6767
6868 var file_list_2 = std.ArrayList(string).init(alloc);
69 defer file_list_2.deinit();
69 errdefer file_list_2.deinit();
7070 for (file_list_1) |item| {
7171 const _a = extras.trimPrefix(item, cdpath);
7272 const _b = extras.trimPrefix(_a, self.clean_path);