diff options
-rw-r--r-- | src/lj_state.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/lj_state.c b/src/lj_state.c index f7647f33..91f35638 100644 --- a/src/lj_state.c +++ b/src/lj_state.c | |||
@@ -155,26 +155,21 @@ static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) | |||
155 | static void close_state(lua_State *L) | 155 | static void close_state(lua_State *L) |
156 | { | 156 | { |
157 | global_State *g = G(L); | 157 | global_State *g = G(L); |
158 | lj_func_closeuv(L, tvref(L->stack)); | ||
159 | lj_gc_freeall(g); | ||
160 | lua_assert(gcref(g->gc.root) == obj2gco(L)); | ||
161 | lua_assert(g->strnum == 0); | ||
162 | lj_trace_freestate(g); | ||
163 | lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); | ||
164 | lj_str_freebuf(g, &g->tmpbuf); | ||
165 | lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); | ||
166 | lua_assert(g->gc.total == sizeof(GG_State)); | ||
158 | #ifndef LUAJIT_USE_SYSMALLOC | 167 | #ifndef LUAJIT_USE_SYSMALLOC |
159 | if (g->allocf == lj_alloc_f) { | 168 | if (g->allocf == lj_alloc_f) |
160 | #if LJ_HASJIT | ||
161 | lj_mcode_free(G2J(g)); | ||
162 | #endif | ||
163 | lj_alloc_destroy(g->allocd); | 169 | lj_alloc_destroy(g->allocd); |
164 | } else | 170 | else |
165 | #endif | 171 | #endif |
166 | { | ||
167 | lj_func_closeuv(L, tvref(L->stack)); | ||
168 | lj_gc_freeall(g); | ||
169 | lua_assert(gcref(g->gc.root) == obj2gco(L)); | ||
170 | lua_assert(g->strnum == 0); | ||
171 | lj_trace_freestate(g); | ||
172 | lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); | ||
173 | lj_str_freebuf(g, &g->tmpbuf); | ||
174 | lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); | ||
175 | lua_assert(g->gc.total == sizeof(GG_State)); | ||
176 | g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); | 172 | g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); |
177 | } | ||
178 | } | 173 | } |
179 | 174 | ||
180 | #if LJ_64 | 175 | #if LJ_64 |