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)
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index f412901..11dac06 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1957,8 +1957,7 @@
if (!shortname && st_new.st_dev == st_old.st_dev
&& st_new.st_ino == st_old.st_ino)
{
- vim_free(tempname);
- tempname = NULL;
+ VIM_CLEAR(tempname);
shortname = TRUE;
break;
}
@@ -5225,8 +5224,7 @@
lnum += regmatch.startpos[0].lnum;
sub_firstlnum += regmatch.startpos[0].lnum;
nmatch -= regmatch.startpos[0].lnum;
- vim_free(sub_firstline);
- sub_firstline = NULL;
+ VIM_CLEAR(sub_firstline);
}
if (sub_firstline == NULL)
@@ -5388,10 +5386,7 @@
sub_firstline + copycol);
if (new_line == NULL)
- {
- vim_free(orig_line);
- orig_line = NULL;
- }
+ VIM_CLEAR(orig_line);
else
{
/* Position the cursor relative to the
@@ -5820,8 +5815,7 @@
if (did_sub)
++sub_nlines;
vim_free(new_start); /* for when substitute was cancelled */
- vim_free(sub_firstline); /* free the copy of the original line */
- sub_firstline = NULL;
+ VIM_CLEAR(sub_firstline); /* free the copy of the original line */
}
line_breakcheck();
@@ -6975,8 +6969,7 @@
&& fnamecmp(e1, fname + 4) != 0)
{
/* Not .txt and not .abx, remove it. */
- vim_free(fnames[i1]);
- fnames[i1] = NULL;
+ VIM_CLEAR(fnames[i1]);
continue;
}
if (e1 - f1 != e2 - f2
@@ -6984,11 +6977,8 @@
continue;
if (fnamecmp(e1, ".txt") == 0
&& fnamecmp(e2, fname + 4) == 0)
- {
/* use .abx instead of .txt */
- vim_free(fnames[i1]);
- fnames[i1] = NULL;
- }
+ VIM_CLEAR(fnames[i1]);
}
}
#endif