summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-new-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-08-20 19:50:18 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-08-20 19:50:18 +0000
commit720f841059a27643e512b0f9ac54c28b316e79d8 (patch)
tree1fd6c606c266b70bc640fe63d054f44396a2d43d /usr.bin/tmux/cmd-new-window.c
parent4ac13be589b12b0ebd28925105fd98cfb8e400e5 (diff)
Hide struct args behind a couple of accessor functions.
Diffstat (limited to 'usr.bin/tmux/cmd-new-window.c')
-rw-r--r--usr.bin/tmux/cmd-new-window.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-new-window.c b/usr.bin/tmux/cmd-new-window.c
index d94f7e8a2bf..a6b1ff7fe04 100644
--- a/usr.bin/tmux/cmd-new-window.c
+++ b/usr.bin/tmux/cmd-new-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-new-window.c,v 1.92 2021/08/20 19:08:36 nicm Exp $ */
+/* $OpenBSD: cmd-new-window.c,v 1.93 2021/08/20 19:50:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -55,12 +55,11 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
struct client *c = cmdq_get_client(item);
struct cmd_find_state *current = cmdq_get_current(item);
struct cmd_find_state *target = cmdq_get_target(item);
- struct spawn_context sc;
+ struct spawn_context sc = { 0 };
struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s;
- struct winlink *wl = target->wl;
+ struct winlink *wl = target->wl, *new_wl = NULL;
int idx = target->idx, before;
- struct winlink *new_wl = NULL;
char *cause = NULL, *cp;
const char *template, *name;
struct cmd_find_state fs;
@@ -101,14 +100,12 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
idx = target->idx;
}
- memset(&sc, 0, sizeof sc);
sc.item = item;
sc.s = s;
sc.tc = tc;
sc.name = args_get(args, 'n');
- sc.argc = args->argc;
- sc.argv = args->argv;
+ args_vector(args, &sc.argc, &sc.argv);
sc.environ = environ_create();
av = args_first_value(args, 'e');
@@ -129,6 +126,8 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
if ((new_wl = spawn_window(&sc, &cause)) == NULL) {
cmdq_error(item, "create window failed: %s", cause);
free(cause);
+ if (sc.argv != NULL)
+ cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
return (CMD_RETURN_ERROR);
}
@@ -150,6 +149,8 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
cmd_find_from_winlink(&fs, new_wl, 0);
cmdq_insert_hook(s, item, &fs, "after-new-window");
+ if (sc.argv != NULL)
+ cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
return (CMD_RETURN_NORMAL);
}