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/misc1.c b/src/misc1.c
index 593dce1..821869a 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -3745,8 +3745,7 @@
char_u *var;
/* In case we are called a second time (when 'encoding' changes). */
- vim_free(homedir);
- homedir = NULL;
+ VIM_CLEAR(homedir);
#ifdef VMS
var = mch_getenv((char_u *)"SYS$LOGIN");
@@ -4358,10 +4357,7 @@
p = vim_strnsave(p, (int)(pend - p));
if (p != NULL && !mch_isdir(p))
- {
- vim_free(p);
- p = NULL;
- }
+ VIM_CLEAR(p);
else
{
#ifdef USE_EXE_NAME
@@ -9775,8 +9771,7 @@
/* If the number of matches is now zero, we fail. */
if (*num_files == 0)
{
- vim_free(*files);
- *files = NULL;
+ VIM_CLEAR(*files);
return FAIL;
}
}
@@ -10031,10 +10026,7 @@
hFind = FindFirstFileW(wn, &wfb);
if (hFind == INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- {
- vim_free(wn);
- wn = NULL;
- }
+ VIM_CLEAR(wn);
}
}
@@ -10122,8 +10114,7 @@
# endif
hFind = FindFirstFile((LPCSTR)buf, &fb);
ok = (hFind != INVALID_HANDLE_VALUE);
- vim_free(matchname);
- matchname = NULL;
+ VIM_CLEAR(matchname);
}
}
@@ -11256,8 +11247,7 @@
if (i != len)
{
EMSG2(_(e_notread), tempname);
- vim_free(buffer);
- buffer = NULL;
+ VIM_CLEAR(buffer);
}
else if (ret_len == NULL)
{