diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-02-10 18:45:26 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-02-10 18:45:26 +0100 |
commit | d23a823669d93fb2a570a039173eefe4856ac806 (patch) | |
tree | 617130258eae70e3bd7ef7b6da9c494ffee7b572 /src/eval.c | |
parent | 42443c7d7fecc3a2a72154bb6139b028438617c2 (diff) |
patch 8.0.1496: clearing a pointer takes two linesv8.0.1496
Problem: Clearing a pointer takes two lines.
Solution: Add VIM_CLEAR() and replace vim_clear(). (Hirohito Higashi,
closes #2629)
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/eval.c b/src/eval.c index 85f607cb77..f20fdda135 100644 --- a/src/eval.c +++ b/src/eval.c @@ -361,10 +361,7 @@ eval_clear(void) { p = &vimvars[i]; if (p->vv_di.di_tv.v_type == VAR_STRING) - { - vim_free(p->vv_str); - p->vv_str = NULL; - } + VIM_CLEAR(p->vv_str); else if (p->vv_di.di_tv.v_type == VAR_LIST) { list_unref(p->vv_list); @@ -569,14 +566,11 @@ var_redir_stop(void) } /* free the collected output */ - vim_free(redir_ga.ga_data); - redir_ga.ga_data = NULL; + VIM_CLEAR(redir_ga.ga_data); - vim_free(redir_lval); - redir_lval = NULL; + VIM_CLEAR(redir_lval); } - vim_free(redir_varname); - redir_varname = NULL; + VIM_CLEAR(redir_varname); } # if defined(FEAT_MBYTE) || defined(PROTO) @@ -1009,10 +1003,7 @@ eval_expr(char_u *arg, char_u **nextcmd) tv = (typval_T *)alloc(sizeof(typval_T)); if (tv != NULL && eval0(arg, tv, nextcmd, TRUE) == FAIL) - { - vim_free(tv); - tv = NULL; - } + VIM_CLEAR(tv); return tv; } @@ -3213,8 +3204,7 @@ get_user_var_name(expand_T *xp, int idx) if (vidx < VV_LEN) return cat_prefix_varname('v', (char_u *)vimvars[vidx++].vv_name); - vim_free(varnamebuf); - varnamebuf = NULL; + VIM_CLEAR(varnamebuf); varnamebuflen = 0; return NULL; } @@ -6096,10 +6086,7 @@ get_env_tv(char_u **arg, typval_T *rettv, int evaluate) /* next try expanding things like $VIM and ${HOME} */ string = expand_env_save(name - 1); if (string != NULL && *string == '$') - { - vim_free(string); - string = NULL; - } + VIM_CLEAR(string); } name[len] = cc; @@ -7116,8 +7103,7 @@ clear_tv(typval_T *varp) func_unref(varp->vval.v_string); /* FALLTHROUGH */ case VAR_STRING: - vim_free(varp->vval.v_string); - varp->vval.v_string = NULL; + VIM_CLEAR(varp->vval.v_string); break; case VAR_PARTIAL: partial_unref(varp->vval.v_partial); |