From 413fc7334bf8ceaea71417d73edef15c99d3a793 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 29 Nov 2001 18:22:22 -0200 Subject: new implementation for lua upvalues (sugested by E.T.): simpler and solves a bug for multi-stacks --- lstate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index a9130455..6e2ba8f1 100644 --- a/lstate.c +++ b/lstate.c @@ -10,6 +10,7 @@ #include "lua.h" #include "ldo.h" +#include "lfunc.h" #include "lgc.h" #include "llex.h" #include "lmem.h" @@ -88,7 +89,7 @@ LUA_API lua_State *lua_newthread (lua_State *OL, int stacksize) { L->errorJmp = NULL; L->callhook = NULL; L->linehook = NULL; - L->opencl = NULL; + L->openupval = NULL; L->allowhooks = 1; L->next = L->previous = L; so.stacksize = stacksize; @@ -105,6 +106,8 @@ LUA_API lua_State *lua_newthread (lua_State *OL, int stacksize) { static void close_state (lua_State *L, lua_State *OL) { + luaF_close(L, L->stack); /* close all upvalues for this thread */ + lua_assert(L->openupval == NULL); if (OL != NULL) { /* are there other threads? */ lua_assert(L->previous != L); L->previous->next = L->next; @@ -116,6 +119,7 @@ static void close_state (lua_State *L, lua_State *OL) { lua_assert(G(L)->rootproto == NULL); lua_assert(G(L)->rootudata == NULL); lua_assert(G(L)->rootcl == NULL); + lua_assert(G(L)->rootupval == NULL); lua_assert(G(L)->roottable == NULL); luaS_freeall(L); luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM); @@ -126,6 +130,7 @@ static void close_state (lua_State *L, lua_State *OL) { luaM_freelem(OL, L); } + LUA_API void lua_close (lua_State *L) { lua_State *OL; lua_assert(L != lua_state || lua_gettop(L) == 0); -- cgit v1.2.3-55-g6feb