diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/option.c | 23 | 
1 files changed, 11 insertions, 12 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 37a5a61d43..6b820ea1ba 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2216,21 +2216,20 @@ set_options_default (    win_comp_scroll(wp);  } -/* - * Set the Vi-default value of a string option. - * Used for 'sh', 'backupskip' and 'term'. - */ -void set_string_default(char *name, char_u *val) +/// Set the Vi-default value of a string option. +/// Used for 'sh', 'backupskip' and 'term'. +/// +/// @param name The name of the option +/// @param val The value of the option +void set_string_default(const char *name, const char_u *val)  { -  char_u      *p; -  int opt_idx; - -  p = vim_strsave(val); -  opt_idx = findoption((char_u *)name); +  int opt_idx = findoption((char_u *)name);    if (opt_idx >= 0) { -    if (options[opt_idx].flags & P_DEF_ALLOCED) +    if (options[opt_idx].flags & P_DEF_ALLOCED) {        free(options[opt_idx].def_val[VI_DEFAULT]); -    options[opt_idx].def_val[VI_DEFAULT] = p; +    } + +    options[opt_idx].def_val[VI_DEFAULT] = (char_u *) xstrdup((char *) val);      options[opt_idx].flags |= P_DEF_ALLOCED;    }  }  | 
