MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / close_state

Function close_state

third-party/lua-5.5.0/src/lstate.c:255–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253
254
255static 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
273LUA_API lua_State *lua_newthread (lua_State *L) {

Callers 2

lua_newstateFunction · 0.70
lua_closeFunction · 0.70

Calls 4

resetCIFunction · 0.85
luaC_freeallobjectsFunction · 0.70
luaD_closeprotectedFunction · 0.70
freestackFunction · 0.70

Tested by

no test coverage detected