LUA_API void lua_close (lua_State *L) { LUA_ASSERT(L != lua_state || lua_gettop(L) == 0, "garbage in C stack"); luaC_collect(L, 1); /* collect all elements */ LUA_ASSERT(L->rootproto == NULL, "list should be empty"); LUA_ASSERT(L->rootcl == NULL, "list should be empty"); LUA_ASSERT(L->roottable == NULL, "list should be empty"); luaS_freeall(L); if (L->stack) L->nblocks -= (L->stack_last - L->stack + 1)*sizeof(TObject); luaM_free(L, L->stack); L->nblocks -= (L->last_tag+1)*sizeof(struct TM); luaM_free(L, L->TMtable); L->nblocks -= (L->refSize)*sizeof(struct Ref); luaM_free(L, L->refArray); L->nblocks -= (L->Mbuffsize)*sizeof(char); luaM_free(L, L->Mbuffer); LUA_ASSERT(L->nblocks == sizeof(lua_State), "wrong count for nblocks"); luaM_free(L, L); LUA_ASSERT(L != lua_state || memdebug_numblocks == 0, "memory leak!"); LUA_ASSERT(L != lua_state || memdebug_total == 0,"memory leak!"); }
LUA_API void lua_collectgarbage (lua_State *L, int step) { luaC_collect(L, step); }