diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-12 15:43:13 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-12 15:43:13 -0300 |
commit | 89e8303f4ea5f1041f3633db7948e7aef17b5226 (patch) | |
tree | d3f6853fd3bc177c4ba728aa71051cd29ba57c89 /lstate.c | |
parent | 89c301d180ef4ef3887fbf54fe2fd43a5c8d183a (diff) | |
download | lua-89e8303f4ea5f1041f3633db7948e7aef17b5226.tar.gz lua-89e8303f4ea5f1041f3633db7948e7aef17b5226.tar.bz2 lua-89e8303f4ea5f1041f3633db7948e7aef17b5226.zip |
more robust treatment of GC tag methods (now they can create new
objects while running...)
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 1.62 2001/04/17 17:35:54 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.63 2001/06/06 18:00:19 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -112,11 +112,14 @@ static void close_state (lua_State *L, lua_State *OL) { | |||
112 | L->next->previous = L->previous; | 112 | L->next->previous = L->previous; |
113 | } | 113 | } |
114 | else if (G(L)) { /* last thread; close global state */ | 114 | else if (G(L)) { /* last thread; close global state */ |
115 | luaC_collect(L, 1); /* collect all elements */ | 115 | while (G(L)->rootudata) { |
116 | luaC_collectudata(L); /* collect all user data */ | ||
117 | luaC_callgcTMudata(L); /* call their tag methods */ | ||
118 | } /* repeat, as tag methods may create new userdata objects */ | ||
119 | luaC_collect(L, 1); /* collect all other elements */ | ||
116 | lua_assert(G(L)->rootproto == NULL); | 120 | lua_assert(G(L)->rootproto == NULL); |
117 | lua_assert(G(L)->rootcl == NULL); | 121 | lua_assert(G(L)->rootcl == NULL); |
118 | lua_assert(G(L)->roottable == NULL); | 122 | lua_assert(G(L)->roottable == NULL); |
119 | lua_assert(G(L)->rootudata == NULL); | ||
120 | luaS_freeall(L); | 123 | luaS_freeall(L); |
121 | luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM); | 124 | luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM); |
122 | luaM_freearray(L, G(L)->Mbuffer, G(L)->Mbuffsize, l_char); | 125 | luaM_freearray(L, G(L)->Mbuffer, G(L)->Mbuffsize, l_char); |