cleaner way to free all objects

This commit is contained in:
Roberto Ierusalimschy
2005-02-10 11:25:02 -02:00
parent 0e60572606
commit 4df8800a01
4 changed files with 40 additions and 43 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lstate.c,v 2.22 2005/01/14 14:19:42 roberto Exp $
** $Id: lstate.c,v 2.23 2005/01/18 17:18:09 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@@ -114,7 +114,7 @@ static void close_state (lua_State *L) {
global_State *g = G(L);
luaF_close(L, L->stack); /* close all upvalues for this thread */
luaC_freeall(L); /* collect all objects */
lua_assert(g->rootgc == NULL);
lua_assert(g->rootgc == obj2gco(L));
lua_assert(g->strt.nuse == 0);
luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
luaZ_freebuffer(L, &g->buff);
@@ -156,8 +156,9 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
g = &((LG *)L)->g;
L->next = NULL;
L->tt = LUA_TTHREAD;
L->marked = g->currentwhite = bitmask(WHITE0BIT);
setbit(L->marked, FIXEDBIT);
g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
L->marked = luaC_white(g);
set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
preinit_state(L, g);
g->realloc = f;
g->ud = ud;