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

Diff for /src/usr.bin/tmux/options.c between version 1.20 and 1.21

version 1.20, 2016/10/10 21:29:23 version 1.21, 2017/01/11 14:56:44
Line 37 
Line 37 
 static int      options_cmp(struct options_entry *, struct options_entry *);  static int      options_cmp(struct options_entry *, struct options_entry *);
 RB_GENERATE_STATIC(options_tree, options_entry, entry, options_cmp);  RB_GENERATE_STATIC(options_tree, options_entry, entry, options_cmp);
   
 static void     options_free1(struct options *, struct options_entry *);  
   
 static int  static int
 options_cmp(struct options_entry *o1, struct options_entry *o2)  options_cmp(struct options_entry *o1, struct options_entry *o2)
 {  {
Line 66 
Line 64 
         free(o);          free(o);
 }  }
   
   static struct options_entry *
   options_new(struct options *oo, const char *name, char **s)
   {
           struct options_entry    *o;
   
           if (s != NULL)
                   *s = NULL;
   
           if ((o = options_find1(oo, name)) == NULL) {
                   o = xmalloc(sizeof *o);
                   o->name = xstrdup(name);
                   RB_INSERT(options_tree, &oo->tree, o);
                   memcpy(&o->style, &grid_default_cell, sizeof o->style);
           } else if (o->type == OPTIONS_STRING) {
                   if (s != NULL)
                           *s = o->str;
                   else
                           free(o->str);
           }
           return (o);
   }
   
 void  void
 options_free(struct options *oo)  options_free(struct options *oo)
 {  {
Line 129 
Line 149 
         va_list                  ap;          va_list                  ap;
         char                    *s;          char                    *s;
   
         s = NULL;  
         if ((o = options_find1(oo, name)) == NULL) {  
                 o = xmalloc(sizeof *o);  
                 o->name = xstrdup(name);  
                 RB_INSERT(options_tree, &oo->tree, o);  
                 memcpy(&o->style, &grid_default_cell, sizeof o->style);  
         } else if (o->type == OPTIONS_STRING)  
                 s = o->str;  
   
         va_start(ap, fmt);          va_start(ap, fmt);
   
           o = options_new(oo, name, &s);
         o->type = OPTIONS_STRING;          o->type = OPTIONS_STRING;
         xvasprintf(&o->str, fmt, ap);          xvasprintf(&o->str, fmt, ap);
         va_end(ap);  
   
         free(s);          free(s);
   
           va_end(ap);
         return (o);          return (o);
 }  }
   
Line 164 
Line 177 
 {  {
         struct options_entry    *o;          struct options_entry    *o;
   
         if ((o = options_find1(oo, name)) == NULL) {          o = options_new(oo, name, NULL);
                 o = xmalloc(sizeof *o);  
                 o->name = xstrdup(name);  
                 RB_INSERT(options_tree, &oo->tree, o);  
                 memcpy(&o->style, &grid_default_cell, sizeof o->style);  
         } else if (o->type == OPTIONS_STRING)  
                 free(o->str);  
   
         o->type = OPTIONS_NUMBER;          o->type = OPTIONS_NUMBER;
         o->num = value;          o->num = value;
   
         return (o);          return (o);
 }  }
   
Line 205 
Line 212 
         if (style_parse(&grid_default_cell, &tmpgc, value) == -1)          if (style_parse(&grid_default_cell, &tmpgc, value) == -1)
                 return (NULL);                  return (NULL);
   
         if (o == NULL) {          o = options_new(oo, name, NULL);
                 o = xmalloc(sizeof *o);  
                 o->name = xstrdup(name);  
                 RB_INSERT(options_tree, &oo->tree, o);  
         } else if (o->type == OPTIONS_STRING)  
                 free(o->str);  
   
         o->type = OPTIONS_STYLE;          o->type = OPTIONS_STYLE;
         memcpy(&o->style, &tmpgc, sizeof o->style);          memcpy(&o->style, &tmpgc, sizeof o->style);
   
         return (o);          return (o);
 }  }
   

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21