aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memline.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-05-25 14:49:43 +0200
committerGitHub <noreply@github.com>2019-05-25 14:49:43 +0200
commit2f023f40b275a904c96d5b287e9e9abe6df1aec7 (patch)
tree36f2b5bec81f7144c5bd3787f33959bd60c59e0e /src/nvim/memline.c
parent4769deb36a54c3b2a4a2d2addb2937c1aa7dd629 (diff)
parenteddd1bff3e7bf8df7405f6b0bfd01a5bb8ba20a9 (diff)
downloadrneovim-2f023f40b275a904c96d5b287e9e9abe6df1aec7.tar.gz
rneovim-2f023f40b275a904c96d5b287e9e9abe6df1aec7.tar.bz2
rneovim-2f023f40b275a904c96d5b287e9e9abe6df1aec7.zip
Merge #10046 from justinmk/xfree
refactor: introduce XFREE_CLEAR()
Diffstat (limited to 'src/nvim/memline.c')
-rw-r--r--src/nvim/memline.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index a071314453..a4d2feb5e3 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -563,8 +563,7 @@ void ml_close(buf_T *buf, int del_file)
if (buf->b_ml.ml_line_lnum != 0 && (buf->b_ml.ml_flags & ML_LINE_DIRTY))
xfree(buf->b_ml.ml_line_ptr);
xfree(buf->b_ml.ml_stack);
- xfree(buf->b_ml.ml_chunksize);
- buf->b_ml.ml_chunksize = NULL;
+ XFREE_CLEAR(buf->b_ml.ml_chunksize);
buf->b_ml.ml_mfp = NULL;
/* Reset the "recovered" flag, give the ATTENTION prompt the next time
@@ -3341,11 +3340,11 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname,
(char_u *)dir_name);
for (;; ) {
- if (fname == NULL) /* must be out of memory */
+ if (fname == NULL) { // must be out of memory
break;
- if ((n = strlen(fname)) == 0) { /* safety check */
- xfree(fname);
- fname = NULL;
+ }
+ if ((n = strlen(fname)) == 0) { // safety check
+ XFREE_CLEAR(fname);
break;
}
// check if the swapfile already exists
@@ -3541,8 +3540,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname,
if (fname[n - 1] == 'a') { /* ".s?a" */
if (fname[n - 2] == 'a') { /* ".saa": tried enough, give up */
EMSG(_("E326: Too many swap files found"));
- xfree(fname);
- fname = NULL;
+ XFREE_CLEAR(fname);
break;
}
--fname[n - 2]; /* ".svz", ".suz", etc. */