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_getln.c b/src/ex_getln.c
index 837d299..a9d6bd4 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -164,8 +164,7 @@
static void
abandon_cmdline(void)
{
- vim_free(ccline.cmdbuff);
- ccline.cmdbuff = NULL;
+ VIM_CLEAR(ccline.cmdbuff);
if (msg_scrolled == 0)
compute_cmdrow();
MSG("");
@@ -500,10 +499,7 @@
&& c != K_KPAGEDOWN && c != K_KPAGEUP
&& c != K_LEFT && c != K_RIGHT
&& (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N)))
- {
- vim_free(lookfor);
- lookfor = NULL;
- }
+ VIM_CLEAR(lookfor);
#endif
/*
@@ -1096,8 +1092,7 @@
)
goto cmdline_not_changed;
- vim_free(ccline.cmdbuff); /* no commandline to return */
- ccline.cmdbuff = NULL;
+ VIM_CLEAR(ccline.cmdbuff); /* no commandline to return */
if (!cmd_silent)
{
#ifdef FEAT_RIGHTLEFT
@@ -3683,10 +3678,7 @@
|| ccline.cmdbuff[i + j] == '?')
break;
if ((int)STRLEN(p2) < j)
- {
- vim_free(p2);
- p2 = NULL;
- }
+ VIM_CLEAR(p2);
}
}
}
@@ -3832,8 +3824,7 @@
{
FreeWild(xp->xp_numfiles, xp->xp_files);
xp->xp_numfiles = -1;
- vim_free(orig_save);
- orig_save = NULL;
+ VIM_CLEAR(orig_save);
}
findex = 0;
@@ -6737,8 +6728,7 @@
else
concat_history(type);
- vim_free(viminfo_history[type]);
- viminfo_history[type] = NULL;
+ VIM_CLEAR(viminfo_history[type]);
viminfo_hisidx[type] = 0;
}
}
@@ -6862,8 +6852,7 @@
for (i = 0; i < viminfo_hisidx[type]; ++i)
if (viminfo_history[type] != NULL)
vim_free(viminfo_history[type][i].hisstr);
- vim_free(viminfo_history[type]);
- viminfo_history[type] = NULL;
+ VIM_CLEAR(viminfo_history[type]);
viminfo_hisidx[type] = 0;
}
}