diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-22 01:02:26 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-05-25 10:07:05 +0200 |
commit | ae846b41dfed16446be6469cb01f12f1eb1fa534 (patch) | |
tree | 2851845f2faf61d5945cb4f1d8761316201a6246 /src/nvim/ex_docmd.c | |
parent | a9d7ec4587d8eb20f12ebecc427ad818fb0e4971 (diff) | |
download | rneovim-ae846b41dfed16446be6469cb01f12f1eb1fa534.tar.gz rneovim-ae846b41dfed16446be6469cb01f12f1eb1fa534.tar.bz2 rneovim-ae846b41dfed16446be6469cb01f12f1eb1fa534.zip |
vim-patch:8.0.1496: VIM_CLEAR()
Problem: Clearing a pointer takes two lines.
Solution: Add VIM_CLEAR() and replace vim_clear(). (Hirohito Higashi,
closes #2629)
vim-patch:8.0.1481
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 9c4a3f389a..979daf24fe 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -431,8 +431,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) { /* Each '|' separated command is stored separately in lines_ga, to * be able to jump to it. Don't use next_cmdline now. */ - xfree(cmdline_copy); - cmdline_copy = NULL; + XFREE_CLEAR(cmdline_copy); /* Check if a function has returned or, unless it has an unclosed * try conditional, aborted. */ @@ -606,12 +605,11 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, current_line = cmd_loop_cookie.current_line; if (next_cmdline == NULL) { - xfree(cmdline_copy); - cmdline_copy = NULL; - /* - * If the command was typed, remember it for the ':' register. - * Do this AFTER executing the command to make :@: work. - */ + XFREE_CLEAR(cmdline_copy); + // + // If the command was typed, remember it for the ':' register. + // Do this AFTER executing the command to make :@: work. + // if (getline_equal(fgetline, cookie, getexline) && new_last_cmdline != NULL) { xfree(last_cmdline); @@ -4842,10 +4840,8 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep, goto fail; } - xfree(cmd->uc_rep); - cmd->uc_rep = NULL; - xfree(cmd->uc_compl_arg); - cmd->uc_compl_arg = NULL; + XFREE_CLEAR(cmd->uc_rep); + XFREE_CLEAR(cmd->uc_compl_arg); break; } @@ -7232,11 +7228,8 @@ static char_u *prev_dir = NULL; #if defined(EXITFREE) void free_cd_dir(void) { - xfree(prev_dir); - prev_dir = NULL; - - xfree(globaldir); - globaldir = NULL; + XFREE_CLEAR(prev_dir); + XFREE_CLEAR(globaldir); } #endif @@ -7247,13 +7240,11 @@ void free_cd_dir(void) void post_chdir(CdScope scope, bool trigger_dirchanged) { // Always overwrite the window-local CWD. - xfree(curwin->w_localdir); - curwin->w_localdir = NULL; + XFREE_CLEAR(curwin->w_localdir); // Overwrite the tab-local CWD for :cd, :tcd. if (scope >= kCdScopeTab) { - xfree(curtab->tp_localdir); - curtab->tp_localdir = NULL; + XFREE_CLEAR(curtab->tp_localdir); } if (scope < kCdScopeGlobal) { @@ -7270,8 +7261,7 @@ void post_chdir(CdScope scope, bool trigger_dirchanged) switch (scope) { case kCdScopeGlobal: // We are now in the global directory, no need to remember its name. - xfree(globaldir); - globaldir = NULL; + XFREE_CLEAR(globaldir); break; case kCdScopeTab: curtab->tp_localdir = (char_u *)xstrdup(cwd); |