0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

updated for version 7.0-084

This commit is contained in:
Bram Moolenaar
2006-09-05 10:59:47 +00:00
parent 203335e4a9
commit 9fecb460fe
5 changed files with 56 additions and 11 deletions

View File

@@ -6074,6 +6074,10 @@ garbage_collect()
tabpage_T *tp; tabpage_T *tp;
#endif #endif
/* Only do this once. */
want_garbage_collect = FALSE;
may_garbage_collect = FALSE;
/* /*
* 1. Go through all accessible variables and mark all lists and dicts * 1. Go through all accessible variables and mark all lists and dicts
* with copyID. * with copyID.
@@ -9636,7 +9640,9 @@ f_garbagecollect(argvars, rettv)
typval_T *argvars; typval_T *argvars;
typval_T *rettv; typval_T *rettv;
{ {
garbage_collect(); /* This is postponed until we are back at the toplevel, because we may be
* using Lists and Dicts internally. E.g.: ":echo [garbagecollect()]". */
want_garbage_collect = TRUE;
} }
/* /*

View File

@@ -1451,6 +1451,7 @@ before_blocking()
{ {
updatescript(0); updatescript(0);
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
if (may_garbage_collect)
garbage_collect(); garbage_collect();
#endif #endif
} }
@@ -1502,6 +1503,13 @@ vgetc()
int i; int i;
#endif #endif
#ifdef FEAT_EVAL
/* Do garbage collection when garbagecollect() was called previously and
* we are now at the toplevel. */
if (may_garbage_collect && want_garbage_collect)
garbage_collect();
#endif
/* /*
* If a character was put back with vungetc, it was already processed. * If a character was put back with vungetc, it was already processed.
* Return it directly. * Return it directly.
@@ -1511,9 +1519,9 @@ vgetc()
c = old_char; c = old_char;
old_char = -1; old_char = -1;
mod_mask = old_mod_mask; mod_mask = old_mod_mask;
return c;
} }
else
{
mod_mask = 0x0; mod_mask = 0x0;
last_recorded_len = 0; last_recorded_len = 0;
for (;;) /* this is done twice if there are modifiers */ for (;;) /* this is done twice if there are modifiers */
@@ -1695,8 +1703,20 @@ vgetc()
} }
#endif #endif
return c; break;
} }
}
#ifdef FEAT_EVAL
/*
* In the main loop "may_garbage_collect" can be set to do garbage
* collection in the first next vgetc(). It's disabled after that to
* avoid internally used Lists and Dicts to be freed.
*/
may_garbage_collect = FALSE;
#endif
return c;
} }
/* /*

View File

@@ -300,9 +300,16 @@ EXTERN except_T *caught_stack INIT(= NULL);
#endif #endif
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
EXTERN scid_T current_SID INIT(= 0); /* ID of script being sourced or /* Garbage collection can only take place when we are sure there are no Lists
was sourced to define the * or Dictionaries being used internally. This is flagged with
current function. */ * "may_garbage_collect" when we are at the toplevel.
* "want_garbage_collect" is set by the garbagecollect() function, which means
* we do garbage collection before waiting for a char at the toplevel. */
EXTERN int may_garbage_collect INIT(= FALSE);
EXTERN int want_garbage_collect INIT(= FALSE);
/* ID of script being sourced or was sourced to define the current function. */
EXTERN scid_T current_SID INIT(= 0);
#endif #endif
#if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL)

View File

@@ -1130,6 +1130,16 @@ main_loop(cmdwin, noexmode)
*/ */
update_curswant(); update_curswant();
#ifdef FEAT_EVAL
/*
* May perform garbage collection when waiting for a character, but
* only at the very toplevel. Otherwise we may be using a List or
* Dict internally somewhere.
* "may_garbage_collect" is reset in vgetc() which is invoked through
* do_exmode() and normal_cmd().
*/
may_garbage_collect = (!cmdwin && !noexmode);
#endif
/* /*
* If we're invoked as ex, do a round of ex commands. * If we're invoked as ex, do a round of ex commands.
* Otherwise, get and execute a normal mode command. * Otherwise, get and execute a normal mode command.

View File

@@ -666,6 +666,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
84,
/**/ /**/
83, 83,
/**/ /**/