From 89e8303f4ea5f1041f3633db7948e7aef17b5226 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 12 Jun 2001 15:43:13 -0300 Subject: more robust treatment of GC tag methods (now they can create new objects while running...) --- lstate.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index 194e92c1..65c1cde4 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 1.62 2001/04/17 17:35:54 roberto Exp roberto $ +** $Id: lstate.c,v 1.63 2001/06/06 18:00:19 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -112,11 +112,14 @@ static void close_state (lua_State *L, lua_State *OL) { L->next->previous = L->previous; } else if (G(L)) { /* last thread; close global state */ - luaC_collect(L, 1); /* collect all elements */ + while (G(L)->rootudata) { + luaC_collectudata(L); /* collect all user data */ + luaC_callgcTMudata(L); /* call their tag methods */ + } /* repeat, as tag methods may create new userdata objects */ + luaC_collect(L, 1); /* collect all other elements */ lua_assert(G(L)->rootproto == NULL); lua_assert(G(L)->rootcl == NULL); lua_assert(G(L)->roottable == NULL); - lua_assert(G(L)->rootudata == NULL); luaS_freeall(L); luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM); luaM_freearray(L, G(L)->Mbuffer, G(L)->Mbuffsize, l_char); -- cgit v1.2.3-55-g6feb