lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 9d6556fd87900d1af408eb180ee9052619c990ea
parent 35707e94f343b3f02cd642602aad00337846b9c7
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Tue, 25 Jun 2002 16:17:20 -0300

userdata are removed from weaktables before invoking their GC fallbacks

Diffstat:
Mlgc.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lgc.c b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 1.137 2002/06/20 20:41:46 roberto Exp roberto $ +** $Id: lgc.c,v 1.138 2002/06/24 17:19:43 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -215,7 +215,7 @@ static void traversetable (GCState *st, Table *h) { int weakvalue = 0; marktable(st, h->metatable); lua_assert(h->lsizenode || h->node == G(st->L)->dummynode); - mode = fasttm(st->L, h->metatable, TM_WEAKMODE); + mode = fasttm(st->L, h->metatable, TM_MODE); if (mode && ttype(mode) == LUA_TSTRING) { /* weak table? */ h->mark = st->toclear; /* must be cleared after GC, ... */ st->toclear = h; /* ...put in the appropriate list */ @@ -458,10 +458,10 @@ void luaC_collectgarbage (lua_State *L) { st.toclear = NULL; markstacks(&st); /* mark all stacks */ propagatemarks(&st); /* mark all reachable objects */ + cleartables(st.toclear); separateudata(L); /* separate userdata to be preserved */ marktmu(&st); /* mark `preserved' userdata */ propagatemarks(&st); /* remark */ - cleartables(st.toclear); luaC_collect(L, 0); checkMbuffer(L); G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */