From 8db89f8efba007bab51dd8b8979a828730892f56 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 20 May 2019 11:34:37 +0000 Subject: [PATCH] Add a helper to allocate a cmd_list. --- cmd-list.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd-list.c b/cmd-list.c index e999c370..282533cf 100644 --- a/cmd-list.c +++ b/cmd-list.c @@ -23,6 +23,17 @@ #include "tmux.h" +static struct cmd_list * +cmd_list_new(void) +{ + struct cmd_list *cmdlist; + + cmdlist = xcalloc(1, sizeof *cmdlist); + cmdlist->references = 1; + TAILQ_INIT(&cmdlist->list); + return (cmdlist); +} + struct cmd_list * cmd_list_parse(int argc, char **argv, const char *file, u_int line, char **cause) @@ -35,9 +46,7 @@ cmd_list_parse(int argc, char **argv, const char *file, u_int line, copy_argv = cmd_copy_argv(argc, argv); - cmdlist = xcalloc(1, sizeof *cmdlist); - cmdlist->references = 1; - TAILQ_INIT(&cmdlist->list); + cmdlist = cmd_list_new(); lastsplit = 0; for (i = 0; i < argc; i++) {