diff options
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 16 |
1 files changed, 2 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.46 2008/08/13 17:01:33 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.47 2008/08/26 13:27:42 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 | */ |
@@ -199,25 +199,13 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | static void callallgcTM (lua_State *L, void *ud) { | ||
203 | UNUSED(ud); | ||
204 | luaC_callAllGCTM(L); /* call GC metamethods for all udata */ | ||
205 | } | ||
206 | |||
207 | |||
208 | LUA_API void lua_close (lua_State *L) { | 202 | LUA_API void lua_close (lua_State *L) { |
209 | L = G(L)->mainthread; /* only the main thread can be closed */ | 203 | L = G(L)->mainthread; /* only the main thread can be closed */ |
210 | lua_lock(L); | 204 | lua_lock(L); |
211 | luaF_close(L, L->stack); /* close all upvalues for this thread */ | 205 | luaF_close(L, L->stack); /* close all upvalues for this thread */ |
212 | luaC_separateudata(L, 1); /* separate all udata with GC metamethods */ | 206 | luaC_separateudata(L, 1); /* separate all udata with GC metamethods */ |
213 | lua_assert(L->next == NULL); | 207 | lua_assert(L->next == NULL); |
214 | L->errfunc = 0; /* no error function during GC metamethods */ | 208 | luaC_callAllGCTM(L); /* call GC metamethods for all udata */ |
215 | do { /* repeat until no more errors */ | ||
216 | L->ci = L->base_ci; | ||
217 | L->base = L->top = L->ci->base; | ||
218 | G(L)->nCcalls = 0; | ||
219 | } while (luaD_rawrunprotected(L, callallgcTM, NULL) != LUA_OK); | ||
220 | lua_assert(G(L)->tobefnz == NULL); | ||
221 | luai_userstateclose(L); | 209 | luai_userstateclose(L); |
222 | close_state(L); | 210 | close_state(L); |
223 | } | 211 | } |