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