new function 'luaC_runtilstate' to advance GC until a "valid" state

This commit is contained in:
Roberto Ierusalimschy
2009-12-11 17:14:59 -02:00
parent 2e51792596
commit a2a2abcba4
4 changed files with 35 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lstring.c,v 2.12 2009/04/17 14:40:13 roberto Exp roberto $
** $Id: lstring.c,v 2.13 2009/04/29 17:09:41 roberto Exp roberto $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
@@ -22,8 +22,8 @@
void luaS_resize (lua_State *L, int newsize) {
int i;
stringtable *tb = &G(L)->strt;
if (G(L)->gcstate == GCSsweepstring)
return; /* cannot resize during GC traverse */
/* cannot resize while GC is traversing strings */
luaC_runtilstate(L, ~GCSsweepstring);
if (newsize > tb->size) {
luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *);
for (i = tb->size; i < newsize; i++) tb->hash[i] = NULL;