aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lstate.c b/lstate.c
index 09bf4ba7..a7e1e540 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 2.42 2007/10/31 15:41:19 roberto Exp roberto $ 2** $Id: lstate.c,v 2.43 2008/02/11 15:45:30 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*/
@@ -107,8 +107,6 @@ static void close_state (lua_State *L) {
107 global_State *g = G(L); 107 global_State *g = G(L);
108 luaF_close(L, L->stack); /* close all upvalues for this thread */ 108 luaF_close(L, L->stack); /* close all upvalues for this thread */
109 luaC_freeall(L); /* collect all objects */ 109 luaC_freeall(L); /* collect all objects */
110 lua_assert(g->rootgc == obj2gco(L));
111 lua_assert(g->strt.nuse == 0);
112 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); 110 luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
113 luaZ_freebuffer(L, &g->buff); 111 luaZ_freebuffer(L, &g->buff);
114 freestack(L, L); 112 freestack(L, L);
@@ -183,7 +181,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
183 g->gray = NULL; 181 g->gray = NULL;
184 g->grayagain = NULL; 182 g->grayagain = NULL;
185 g->weak = g->ephemeron = g->allweak = NULL; 183 g->weak = g->ephemeron = g->allweak = NULL;
186 g->tmudata = NULL; 184 g->tmudata = g->tobefnz = NULL;
187 g->totalbytes = sizeof(LG); 185 g->totalbytes = sizeof(LG);
188 g->gcpause = LUAI_GCPAUSE; 186 g->gcpause = LUAI_GCPAUSE;
189 g->gcstepmul = LUAI_GCMUL; 187 g->gcstepmul = LUAI_GCMUL;
@@ -210,14 +208,15 @@ LUA_API void lua_close (lua_State *L) {
210 L = G(L)->mainthread; /* only the main thread can be closed */ 208 L = G(L)->mainthread; /* only the main thread can be closed */
211 lua_lock(L); 209 lua_lock(L);
212 luaF_close(L, L->stack); /* close all upvalues for this thread */ 210 luaF_close(L, L->stack); /* close all upvalues for this thread */
213 luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ 211 luaC_separateudata(L, 1); /* separate all udata with GC metamethods */
212 lua_assert(G(L)->tmudata == NULL);
214 L->errfunc = 0; /* no error function during GC metamethods */ 213 L->errfunc = 0; /* no error function during GC metamethods */
215 do { /* repeat until no more errors */ 214 do { /* repeat until no more errors */
216 L->ci = L->base_ci; 215 L->ci = L->base_ci;
217 L->base = L->top = L->ci->base; 216 L->base = L->top = L->ci->base;
218 G(L)->nCcalls = 0; 217 G(L)->nCcalls = 0;
219 } while (luaD_rawrunprotected(L, callallgcTM, NULL) != LUA_OK); 218 } while (luaD_rawrunprotected(L, callallgcTM, NULL) != LUA_OK);
220 lua_assert(G(L)->tmudata == NULL); 219 lua_assert(G(L)->tobefnz == NULL);
221 luai_userstateclose(L); 220 luai_userstateclose(L);
222 close_state(L); 221 close_state(L);
223} 222}