[BACK]Return to cmd-queue.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-queue.c between version 1.48 and 1.49

version 1.48, 2017/02/03 11:57:27 version 1.49, 2017/04/21 14:01:19
Line 102 
Line 102 
 static void  static void
 cmdq_remove(struct cmdq_item *item)  cmdq_remove(struct cmdq_item *item)
 {  {
         if (item->formats != NULL)          if (item->shared != NULL && --item->shared->references == 0) {
                 format_free(item->formats);                  if (item->shared->formats != NULL)
                           format_free(item->shared->formats);
                   free(item->shared);
           }
   
         if (item->client != NULL)          if (item->client != NULL)
                 server_client_unref(item->client);                  server_client_unref(item->client);
Line 150 
Line 153 
         struct cmd              *cmd;          struct cmd              *cmd;
         u_int                    group = cmdq_next_group();          u_int                    group = cmdq_next_group();
         char                    *tmp;          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) {          TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
                 xasprintf(&tmp, "command[%s]", cmd->entry->name);                  xasprintf(&tmp, "command[%s]", cmd->entry->name);
   
Line 161 
Line 171 
                 item->group = group;                  item->group = group;
                 item->flags = flags;                  item->flags = flags;
   
                   item->shared = shared;
                 item->cmdlist = cmdlist;                  item->cmdlist = cmdlist;
                 item->cmd = cmd;                  item->cmd = cmd;
   
                 if (current != NULL)                  shared->references++;
                         cmd_find_copy_state(&item->current, current);  
                 if (m != NULL)  
                         memcpy(&item->mouse, m, sizeof item->mouse);  
                 cmdlist->references++;                  cmdlist->references++;
   
                 if (first == NULL)                  if (first == NULL)
Line 258 
Line 266 
 void  void
 cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)  cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)
 {  {
           struct cmdq_shared      *shared = item->shared;
         va_list                  ap;          va_list                  ap;
         struct cmdq_item        *loop;  
         char                    *value;          char                    *value;
   
         va_start(ap, fmt);          va_start(ap, fmt);
         xvasprintf(&value, fmt, ap);          xvasprintf(&value, fmt, ap);
         va_end(ap);          va_end(ap);
   
         for (loop = item; loop != NULL; loop = item->next) {          if (shared->formats == NULL)
                 if (loop->formats == NULL)                  shared->formats = format_create(NULL, FORMAT_NONE, 0);
                         loop->formats = format_create(NULL, FORMAT_NONE, 0);          format_add(shared->formats, key, "%s", value);
                 format_add(loop->formats, key, "%s", value);  
         }  
   
         free(value);          free(value);
 }  }

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49