diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-02-10 11:25:02 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-02-10 11:25:02 -0200 |
commit | 4df8800a01c7e44800ce59339c66b9257cd75c2a (patch) | |
tree | 226ae5cfc06164f6f01e33d778336c1ffd561d72 /lstate.c | |
parent | 0e60572606684458b18febfcef0bc68235b461f4 (diff) | |
download | lua-4df8800a01c7e44800ce59339c66b9257cd75c2a.tar.gz lua-4df8800a01c7e44800ce59339c66b9257cd75c2a.tar.bz2 lua-4df8800a01c7e44800ce59339c66b9257cd75c2a.zip |
cleaner way to free all objects
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.22 2005/01/14 14:19:42 roberto Exp $ | 2 | ** $Id: lstate.c,v 2.23 2005/01/18 17:18:09 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -114,7 +114,7 @@ static void close_state (lua_State *L) { | |||
114 | global_State *g = G(L); | 114 | global_State *g = G(L); |
115 | luaF_close(L, L->stack); /* close all upvalues for this thread */ | 115 | luaF_close(L, L->stack); /* close all upvalues for this thread */ |
116 | luaC_freeall(L); /* collect all objects */ | 116 | luaC_freeall(L); /* collect all objects */ |
117 | lua_assert(g->rootgc == NULL); | 117 | lua_assert(g->rootgc == obj2gco(L)); |
118 | lua_assert(g->strt.nuse == 0); | 118 | lua_assert(g->strt.nuse == 0); |
119 | luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); | 119 | luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); |
120 | luaZ_freebuffer(L, &g->buff); | 120 | luaZ_freebuffer(L, &g->buff); |
@@ -156,8 +156,9 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
156 | g = &((LG *)L)->g; | 156 | g = &((LG *)L)->g; |
157 | L->next = NULL; | 157 | L->next = NULL; |
158 | L->tt = LUA_TTHREAD; | 158 | L->tt = LUA_TTHREAD; |
159 | L->marked = g->currentwhite = bitmask(WHITE0BIT); | 159 | g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); |
160 | setbit(L->marked, FIXEDBIT); | 160 | L->marked = luaC_white(g); |
161 | set2bits(L->marked, FIXEDBIT, SFIXEDBIT); | ||
161 | preinit_state(L, g); | 162 | preinit_state(L, g); |
162 | g->realloc = f; | 163 | g->realloc = f; |
163 | g->ud = ud; | 164 | g->ud = ud; |