Fix memory leak in auth CLI command

This commit is contained in:
Bob Farrell 2024-11-13 20:15:24 +00:00
parent 2dd2f7ae74
commit f9c6f9f38f

View File

@ -21,16 +21,16 @@ pub const Options = struct {
/// Run the `jetzig database` command. /// Run the `jetzig database` command.
pub fn run( pub fn run(
allocator: std.mem.Allocator, parent_allocator: std.mem.Allocator,
options: Options, options: Options,
writer: anytype, writer: anytype,
T: type, T: type,
main_options: T, main_options: T,
) !void { ) !void {
_ = options; _ = options;
var arena = std.heap.ArenaAllocator.init(allocator); var arena = std.heap.ArenaAllocator.init(parent_allocator);
defer arena.deinit(); defer arena.deinit();
const alloc = arena.allocator(); const allocator = arena.allocator();
const Action = enum { user_create }; const Action = enum { user_create };
const map = std.StaticStringMap(Action).initComptime(.{ const map = std.StaticStringMap(Action).initComptime(.{
@ -50,7 +50,7 @@ pub fn run(
try args.printHelp(Options, "jetzig database", writer); try args.printHelp(Options, "jetzig database", writer);
break :blk {}; break :blk {};
} else if (action == null) blk: { } else if (action == null) blk: {
const available_help = try std.mem.join(alloc, "|", map.keys()); const available_help = try std.mem.join(allocator, "|", map.keys());
std.debug.print("Missing sub-command. Expected: [{s}]\n", .{available_help}); std.debug.print("Missing sub-command. Expected: [{s}]\n", .{available_help});
break :blk error.JetzigCommandError; break :blk error.JetzigCommandError;
} else if (action) |capture| } else if (action) |capture|