| 197 | |
| 198 | |
| 199 | LUA_API void lua_close (lua_State *L) { |
| 200 | L = G(L)->mainthread; /* only the main thread can be closed */ |
| 201 | lua_lock(L); |
| 202 | luaF_close(L, L->stack); /* close all upvalues for this thread */ |
| 203 | luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ |
| 204 | L->errfunc = 0; /* no error function during GC metamethods */ |
| 205 | do { /* repeat until no more errors */ |
| 206 | L->ci = L->base_ci; |
| 207 | L->base = L->top = L->ci->base; |
| 208 | L->nCcalls = L->baseCcalls = 0; |
| 209 | } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); |
| 210 | lua_assert(G(L)->tmudata == NULL); |
| 211 | luai_userstateclose(L); |
| 212 | close_state(L); |
| 213 | } |
| 214 |
no test coverage detected