=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-queue.c,v retrieving revision 1.48 retrieving revision 1.49 diff -c -r1.48 -r1.49 *** src/usr.bin/tmux/cmd-queue.c 2017/02/03 11:57:27 1.48 --- src/usr.bin/tmux/cmd-queue.c 2017/04/21 14:01:19 1.49 *************** *** 1,4 **** ! /* $OpenBSD: cmd-queue.c,v 1.48 2017/02/03 11:57:27 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-queue.c,v 1.49 2017/04/21 14:01:19 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott *************** *** 102,109 **** static void cmdq_remove(struct cmdq_item *item) { ! if (item->formats != NULL) ! format_free(item->formats); if (item->client != NULL) server_client_unref(item->client); --- 102,112 ---- static void cmdq_remove(struct cmdq_item *item) { ! if (item->shared != NULL && --item->shared->references == 0) { ! if (item->shared->formats != NULL) ! format_free(item->shared->formats); ! free(item->shared); ! } if (item->client != NULL) server_client_unref(item->client); *************** *** 150,156 **** --- 153,166 ---- struct cmd *cmd; u_int group = cmdq_next_group(); char *tmp; + struct cmdq_shared *shared; + shared = xcalloc(1, sizeof *shared); + if (current != NULL) + cmd_find_copy_state(&shared->current, current); + if (m != NULL) + memcpy(&shared->mouse, m, sizeof shared->mouse); + TAILQ_FOREACH(cmd, &cmdlist->list, qentry) { xasprintf(&tmp, "command[%s]", cmd->entry->name); *************** *** 161,173 **** item->group = group; item->flags = flags; item->cmdlist = cmdlist; item->cmd = cmd; ! if (current != NULL) ! cmd_find_copy_state(&item->current, current); ! if (m != NULL) ! memcpy(&item->mouse, m, sizeof item->mouse); cmdlist->references++; if (first == NULL) --- 171,181 ---- item->group = group; item->flags = flags; + item->shared = shared; item->cmdlist = cmdlist; item->cmd = cmd; ! shared->references++; cmdlist->references++; if (first == NULL) *************** *** 258,276 **** void cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...) { va_list ap; - struct cmdq_item *loop; char *value; va_start(ap, fmt); xvasprintf(&value, fmt, ap); va_end(ap); ! for (loop = item; loop != NULL; loop = item->next) { ! if (loop->formats == NULL) ! loop->formats = format_create(NULL, FORMAT_NONE, 0); ! format_add(loop->formats, key, "%s", value); ! } free(value); } --- 266,282 ---- void cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...) { + struct cmdq_shared *shared = item->shared; va_list ap; char *value; va_start(ap, fmt); xvasprintf(&value, fmt, ap); va_end(ap); ! if (shared->formats == NULL) ! shared->formats = format_create(NULL, FORMAT_NONE, 0); ! format_add(shared->formats, key, "%s", value); free(value); }