4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: The garbage collector may do its work while some Lists or
12 Dictionaries are used internally, e.g., by ":echo" that runs into
13 the more-prompt or ":echo [garbagecollect()]".
14 Solution: Only do garbage collection when waiting for a character at the
15 toplevel. Let garbagecollect() set a flag that is handled at the
16 toplevel before waiting for a character.
17 Files: src/eval.c, src/getchar.c, src/globals.h, src/main.c
20 *** ../vim-7.0.083/src/eval.c Sun Sep 3 15:38:02 2006
21 --- src/eval.c Tue Sep 5 11:49:38 2006
28 + /* Only do this once. */
29 + want_garbage_collect = FALSE;
30 + may_garbage_collect = FALSE;
33 * 1. Go through all accessible variables and mark all lists and dicts
48 ! /* This is postponed until we are back at the toplevel, because we may be
49 ! * using Lists and Dicts internally. E.g.: ":echo [garbagecollect()]". */
50 ! want_garbage_collect = TRUE;
54 *** ../vim-7.0.083/src/getchar.c Wed May 3 23:19:24 2006
55 --- src/getchar.c Tue Sep 5 12:55:54 2006
69 ! if (may_garbage_collect)
81 + /* Do garbage collection when garbagecollect() was called previously and
82 + * we are now at the toplevel. */
83 + if (may_garbage_collect && want_garbage_collect)
88 * If a character was put back with vungetc, it was already processed.
94 mod_mask = old_mod_mask;
99 ! last_recorded_len = 0;
100 ! for (;;) /* this is done twice if there are modifiers */
102 if (mod_mask) /* no mapping after modifier has been read */
108 mod_mask = old_mod_mask;
113 + last_recorded_len = 0;
114 + for (;;) /* this is done twice if there are modifiers */
116 if (mod_mask) /* no mapping after modifier has been read */
139 + * In the main loop "may_garbage_collect" can be set to do garbage
140 + * collection in the first next vgetc(). It's disabled after that to
141 + * avoid internally used Lists and Dicts to be freed.
143 + may_garbage_collect = FALSE;
150 *** ../vim-7.0.083/src/globals.h Sat Sep 2 14:52:41 2006
151 --- src/globals.h Tue Sep 5 11:46:10 2006
157 ! EXTERN scid_T current_SID INIT(= 0); /* ID of script being sourced or
158 ! was sourced to define the
159 ! current function. */
162 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL)
167 ! /* Garbage collection can only take place when we are sure there are no Lists
168 ! * or Dictionaries being used internally. This is flagged with
169 ! * "may_garbage_collect" when we are at the toplevel.
170 ! * "want_garbage_collect" is set by the garbagecollect() function, which means
171 ! * we do garbage collection before waiting for a char at the toplevel. */
172 ! EXTERN int may_garbage_collect INIT(= FALSE);
173 ! EXTERN int want_garbage_collect INIT(= FALSE);
175 ! /* ID of script being sourced or was sourced to define the current function. */
176 ! EXTERN scid_T current_SID INIT(= 0);
179 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL)
180 *** ../vim-7.0.083/src/main.c Tue Aug 29 17:28:56 2006
181 --- src/main.c Tue Sep 5 12:33:47 2006
190 + * May perform garbage collection when waiting for a character, but
191 + * only at the very toplevel. Otherwise we may be using a List or
192 + * Dict internally somewhere.
193 + * "may_garbage_collect" is reset in vgetc() which is invoked through
194 + * do_exmode() and normal_cmd().
196 + may_garbage_collect = (!cmdwin && !noexmode);
199 * If we're invoked as ex, do a round of ex commands.
200 * Otherwise, get and execute a normal mode command.
201 *** ../vim-7.0.083/src/version.c Sun Sep 3 16:39:51 2006
202 --- src/version.c Tue Sep 5 12:51:28 2006
206 { /* Add new patch number below this line */
212 LAUNCELOT: At last! A call! A cry of distress ...
213 (he draws his sword, and turns to CONCORDE)
214 Concorde! Brave, Concorde ... you shall not have died in vain!
215 CONCORDE: I'm not quite dead, sir ...
216 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
218 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
219 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
220 \\\ download, build and distribute -- http://www.A-A-P.org ///
221 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///