aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/memfile.c')
-rw-r--r--src/nvim/memfile.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index 6e8d8f9972..82369b739a 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -613,7 +613,6 @@ static bhdr_T *mf_release(memfile_T *mfp, int page_count)
{
bhdr_T *hp;
int need_release;
- buf_T *buf;
/* don't release while in mf_close_file() */
if (mf_dont_release)
@@ -632,11 +631,16 @@ static bhdr_T *mf_release(memfile_T *mfp, int page_count)
*/
if (mfp->mf_fd < 0 && need_release && p_uc) {
/* find for which buffer this memfile is */
- for (buf = firstbuf; buf != NULL; buf = buf->b_next)
- if (buf->b_ml.ml_mfp == mfp)
+ buf_T *buf = NULL;
+ FOR_ALL_BUFFERS(bp) {
+ if (bp->b_ml.ml_mfp == mfp) {
+ buf = bp;
break;
- if (buf != NULL && buf->b_may_swap)
+ }
+ }
+ if (buf != NULL && buf->b_may_swap) {
ml_open_file(buf);
+ }
}
/*
@@ -686,12 +690,11 @@ static bhdr_T *mf_release(memfile_T *mfp, int page_count)
*/
int mf_release_all(void)
{
- buf_T *buf;
memfile_T *mfp;
bhdr_T *hp;
int retval = FALSE;
- for (buf = firstbuf; buf != NULL; buf = buf->b_next) {
+ FOR_ALL_BUFFERS(buf) {
mfp = buf->b_ml.ml_mfp;
if (mfp != NULL) {
/* If no swap file yet, may open one */