| 253 | |
| 254 | |
| 255 | static void close_state (lua_State *L) { |
| 256 | global_State *g = G(L); |
| 257 | if (!completestate(g)) /* closing a partially built state? */ |
| 258 | luaC_freeallobjects(L); /* just collect its objects */ |
| 259 | else { /* closing a fully built state */ |
| 260 | resetCI(L); |
| 261 | luaD_closeprotected(L, 1, LUA_OK); /* close all upvalues */ |
| 262 | L->top.p = L->stack.p + 1; /* empty the stack to run finalizers */ |
| 263 | luaC_freeallobjects(L); /* collect all objects */ |
| 264 | luai_userstateclose(L); |
| 265 | } |
| 266 | luaM_freearray(L, G(L)->strt.hash, cast_sizet(G(L)->strt.size)); |
| 267 | freestack(L); |
| 268 | lua_assert(gettotalbytes(g) == sizeof(global_State)); |
| 269 | (*g->frealloc)(g->ud, g, sizeof(global_State), 0); /* free main block */ |
| 270 | } |
| 271 | |
| 272 | |
| 273 | LUA_API lua_State *lua_newthread (lua_State *L) { |
no test coverage detected