diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-25 14:49:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-25 14:49:43 +0200 |
commit | 2f023f40b275a904c96d5b287e9e9abe6df1aec7 (patch) | |
tree | 36f2b5bec81f7144c5bd3787f33959bd60c59e0e /src/nvim/ex_docmd.c | |
parent | 4769deb36a54c3b2a4a2d2addb2937c1aa7dd629 (diff) | |
parent | eddd1bff3e7bf8df7405f6b0bfd01a5bb8ba20a9 (diff) | |
download | rneovim-2f023f40b275a904c96d5b287e9e9abe6df1aec7.tar.gz rneovim-2f023f40b275a904c96d5b287e9e9abe6df1aec7.tar.bz2 rneovim-2f023f40b275a904c96d5b287e9e9abe6df1aec7.zip |
Merge #10046 from justinmk/xfree
refactor: introduce XFREE_CLEAR()
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); |