4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When 'swapfile' is switched off in an empty file it is possible
12 that not all blocks are loaded into memory, causing ml_get errors
14 Solution: Rename "dont_release" to "mf_dont_release" and also use it to
15 avoid using the cached line and locked block.
16 Files: src/globals.h, src/memfile.c, src/memline.c
19 *** ../vim-7.0.191/src/globals.h Tue Jan 9 15:15:36 2007
20 --- src/globals.h Wed Feb 7 03:29:52 2007
24 EXTERN buf_T *firstbuf INIT(= NULL); /* first buffer */
25 EXTERN buf_T *lastbuf INIT(= NULL); /* last buffer */
26 EXTERN buf_T *curbuf INIT(= NULL); /* currently active buffer */
28 + /* Flag that is set when switching off 'swapfile'. It means that all blocks
29 + * are to be loaded into memory. Shouldn't be global... */
30 + EXTERN int mf_dont_release INIT(= FALSE); /* don't release blocks */
33 * List of files being edited (global argument list). curwin->w_alist points
34 *** ../vim-7.0.191/src/memfile.c Tue Nov 7 18:02:19 2006
35 --- src/memfile.c Wed Feb 7 03:22:11 2007
38 #define MEMFILE_PAGE_SIZE 4096 /* default page size */
40 static long_u total_mem_used = 0; /* total memory used for memfiles */
41 - static int dont_release = FALSE; /* don't release blocks */
43 static void mf_ins_hash __ARGS((memfile_T *, bhdr_T *));
44 static void mf_rem_hash __ARGS((memfile_T *, bhdr_T *));
50 /* get all blocks in memory by accessing all lines (clumsy!) */
51 ! dont_release = TRUE;
52 for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum)
53 (void)ml_get_buf(buf, lnum, FALSE);
54 ! dont_release = FALSE;
55 /* TODO: should check if all blocks are really in core */
61 /* get all blocks in memory by accessing all lines (clumsy!) */
62 ! mf_dont_release = TRUE;
63 for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum)
64 (void)ml_get_buf(buf, lnum, FALSE);
65 ! mf_dont_release = FALSE;
66 /* TODO: should check if all blocks are really in core */
73 /* don't release while in mf_close_file() */
81 /* don't release while in mf_close_file() */
82 ! if (mf_dont_release)
86 *** ../vim-7.0.191/src/memline.c Tue Jan 9 15:15:36 2007
87 --- src/memline.c Wed Feb 7 03:29:31 2007
91 * See if it is the same line as requested last time.
92 * Otherwise may need to flush last used line.
94 ! if (buf->b_ml.ml_line_lnum != lnum)
100 * See if it is the same line as requested last time.
101 * Otherwise may need to flush last used line.
102 + * Don't use the last used line when 'swapfile' is reset, need to load all
105 ! if (buf->b_ml.ml_line_lnum != lnum || mf_dont_release)
111 * If not, flush and release the locked block.
112 * Don't do this for ML_INSERT_SAME, because the stack need to be updated.
113 * Don't do this for ML_FLUSH, because we want to flush the locked block.
115 if (buf->b_ml.ml_locked)
117 ! if (ML_SIMPLE(action) && buf->b_ml.ml_locked_low <= lnum
118 ! && buf->b_ml.ml_locked_high >= lnum)
120 ! /* remember to update pointer blocks and stack later */
121 if (action == ML_INSERT)
123 ++(buf->b_ml.ml_locked_lineadd);
125 * If not, flush and release the locked block.
126 * Don't do this for ML_INSERT_SAME, because the stack need to be updated.
127 * Don't do this for ML_FLUSH, because we want to flush the locked block.
128 + * Don't do this when 'swapfile' is reset, we want to load all the blocks.
130 if (buf->b_ml.ml_locked)
132 ! if (ML_SIMPLE(action)
133 ! && buf->b_ml.ml_locked_low <= lnum
134 ! && buf->b_ml.ml_locked_high >= lnum
135 ! && !mf_dont_release)
137 ! /* remember to update pointer blocks and stack later */
138 if (action == ML_INSERT)
140 ++(buf->b_ml.ml_locked_lineadd);
141 *** ../vim-7.0.191/src/version.c Sun Feb 4 02:59:04 2007
142 --- src/version.c Wed Feb 7 03:40:28 2007
146 { /* Add new patch number below this line */
152 From "know your smileys":
153 %-) After staring at screen for 15 hours
155 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
156 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
157 \\\ download, build and distribute -- http://www.A-A-P.org ///
158 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///