summaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-25 16:17:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-25 16:17:42 -0300
commit9d6556fd87900d1af408eb180ee9052619c990ea (patch)
tree0adb0e31857720ce6d6731e3053b2e1df7288c6b /lgc.c
parent35707e94f343b3f02cd642602aad00337846b9c7 (diff)
downloadlua-9d6556fd87900d1af408eb180ee9052619c990ea.tar.gz
lua-9d6556fd87900d1af408eb180ee9052619c990ea.tar.bz2
lua-9d6556fd87900d1af408eb180ee9052619c990ea.zip
userdata are removed from weaktables before invoking their GC fallbacks
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lgc.c b/lgc.c
index 8e83fec2..c7429c26 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.137 2002/06/20 20:41:46 roberto Exp roberto $ 2** $Id: lgc.c,v 1.138 2002/06/24 17:19:43 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -215,7 +215,7 @@ static void traversetable (GCState *st, Table *h) {
215 int weakvalue = 0; 215 int weakvalue = 0;
216 marktable(st, h->metatable); 216 marktable(st, h->metatable);
217 lua_assert(h->lsizenode || h->node == G(st->L)->dummynode); 217 lua_assert(h->lsizenode || h->node == G(st->L)->dummynode);
218 mode = fasttm(st->L, h->metatable, TM_WEAKMODE); 218 mode = fasttm(st->L, h->metatable, TM_MODE);
219 if (mode && ttype(mode) == LUA_TSTRING) { /* weak table? */ 219 if (mode && ttype(mode) == LUA_TSTRING) { /* weak table? */
220 h->mark = st->toclear; /* must be cleared after GC, ... */ 220 h->mark = st->toclear; /* must be cleared after GC, ... */
221 st->toclear = h; /* ...put in the appropriate list */ 221 st->toclear = h; /* ...put in the appropriate list */
@@ -458,10 +458,10 @@ void luaC_collectgarbage (lua_State *L) {
458 st.toclear = NULL; 458 st.toclear = NULL;
459 markstacks(&st); /* mark all stacks */ 459 markstacks(&st); /* mark all stacks */
460 propagatemarks(&st); /* mark all reachable objects */ 460 propagatemarks(&st); /* mark all reachable objects */
461 cleartables(st.toclear);
461 separateudata(L); /* separate userdata to be preserved */ 462 separateudata(L); /* separate userdata to be preserved */
462 marktmu(&st); /* mark `preserved' userdata */ 463 marktmu(&st); /* mark `preserved' userdata */
463 propagatemarks(&st); /* remark */ 464 propagatemarks(&st); /* remark */
464 cleartables(st.toclear);
465 luaC_collect(L, 0); 465 luaC_collect(L, 0);
466 checkMbuffer(L); 466 checkMbuffer(L);
467 G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */ 467 G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */