From d23a823669d93fb2a570a039173eefe4856ac806 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 10 Feb 2018 18:45:26 +0100 Subject: patch 8.0.1496: clearing a pointer takes two lines Problem: Clearing a pointer takes two lines. Solution: Add VIM_CLEAR() and replace vim_clear(). (Hirohito Higashi, closes #2629) --- src/regexp.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/regexp.c') diff --git a/src/regexp.c b/src/regexp.c index 7f5e265eb8..d07391eefb 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -3996,10 +3996,7 @@ theend: /* Free "reg_tofree" when it's a bit big. * Free regstack and backpos if they are bigger than their initial size. */ if (reg_tofreelen > 400) - { - vim_free(reg_tofree); - reg_tofree = NULL; - } + VIM_CLEAR(reg_tofree); if (regstack.ga_maxlen > REGSTACK_INITIAL) ga_clear(®stack); if (backpos.ga_maxlen > BACKPOS_INITIAL) @@ -7521,8 +7518,7 @@ vim_regsub_both( { STRCPY(dest, eval_result); dst += STRLEN(eval_result); - vim_free(eval_result); - eval_result = NULL; + VIM_CLEAR(eval_result); } } else @@ -8150,7 +8146,7 @@ vim_regcomp(char_u *expr_arg, int re_flags) * First try the NFA engine, unless backtracking was requested. */ if (regexp_engine != BACKTRACKING_ENGINE) - prog = nfa_regengine.regcomp(expr, + prog = nfa_regengine.regcomp(expr, re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0)); else prog = bt_regengine.regcomp(expr, re_flags); @@ -8170,7 +8166,7 @@ vim_regcomp(char_u *expr_arg, int re_flags) } else EMSG2("(NFA) Could not open \"%s\" to write !!!", - BT_REGEXP_DEBUG_LOG_NAME); + BT_REGEXP_DEBUG_LOG_NAME); } #endif /* @@ -8341,10 +8337,10 @@ vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col) long vim_regexec_multi( regmmatch_T *rmp, - win_T *win, /* window in which to search or NULL */ - buf_T *buf, /* buffer in which to search */ - linenr_T lnum, /* nr of line to start looking for match */ - colnr_T col, /* column to start looking for match */ + win_T *win, /* window in which to search or NULL */ + buf_T *buf, /* buffer in which to search */ + linenr_T lnum, /* nr of line to start looking for match */ + colnr_T col, /* column to start looking for match */ proftime_T *tm, /* timeout limit or NULL */ int *timed_out) /* flag is set when timeout limit reached */ { -- cgit v1.2.3