~gpanders/wk

387c5bee5fba7c1b6506aa746578c20d4b4c4705 — Greg Anders 8 months ago 10dbffb
Plug a few memory leaks
2 files changed, 5 insertions(+), 0 deletions(-)

M src/cmd/list.zig
M src/main.zig
M src/cmd/list.zig => src/cmd/list.zig +2 -0
@@ 6,6 6,8 @@ pub const usage = "l|list";

pub fn run(ext: []const u8, allocator: *std.mem.Allocator) !void {
    const zettels = try util.getZettels(ext, allocator);
    defer allocator.free(zettels);

    for (zettels) |item| {
        try stdout.print("{}\n", .{item[0 .. item.len - ext.len]});
    }

M src/main.zig => src/main.zig +3 -0
@@ 32,6 32,7 @@ fn zettelDir(allocator: *std.mem.Allocator) ![]const u8 {

fn parseArgs(allocator: *std.mem.Allocator) ![][]const u8 {
    var arglist = std.ArrayList([]const u8).init(allocator);
    defer arglist.deinit();

    var args = std.process.args();
    while (args.next(allocator)) |item_or_error| {


@@ 49,6 50,8 @@ pub fn main() anyerror!void {
    var allocator = &arena.allocator;

    const arglist = try parseArgs(allocator);
    defer allocator.free(arglist);

    const exe = arglist[0];
    if (arglist.len == 1) {
        printUsage(exe);