From 11a70220670f25a9929439f0b27331f09f05235c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 8 May 2000 16:32:53 -0300 Subject: global variables are stored in a Lua table --- lgc.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'lgc.c') diff --git a/lgc.c b/lgc.c index ac213df2..32dd6471 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 1.46 2000/03/30 20:55:50 roberto Exp roberto $ +** $Id: lgc.c,v 1.47 2000/04/14 18:12:35 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -77,18 +77,6 @@ static void hashmark (lua_State *L, Hash *h) { } -static void travglobal (lua_State *L) { - GlobalVar *gv; - for (gv=L->rootglobal; gv; gv=gv->next) { - LUA_ASSERT(L, gv->name->u.s.gv == gv, "inconsistent global name"); - if (gv->value.ttype != TAG_NIL) { - strmark(L, gv->name); /* cannot collect non nil global variables */ - markobject(L, &gv->value); - } - } -} - - static void travstack (lua_State *L) { int i; for (i = (L->top-1)-L->stack; i>=0; i--) @@ -173,20 +161,6 @@ static void collecttable (lua_State *L) { } -/* -** remove from the global list globals whose names will be collected -** (the global itself is freed when its name is freed) -*/ -static void clear_global_list (lua_State *L, int limit) { - GlobalVar **p = &L->rootglobal; - GlobalVar *next; - while ((next = *p) != NULL) { - if (next->name->marked >= limit) p = &next->next; - else *p = next->next; - } -} - - /* ** collect all elements with `marked' < `limit'. ** with limit=1, that means all unmarked elements; @@ -196,7 +170,6 @@ static void collectstring (lua_State *L, int limit) { TObject o; /* to call userdata `gc' tag method */ int i; ttype(&o) = TAG_USERDATA; - clear_global_list(L, limit); for (i=0; istring_root[i]; int j; @@ -228,7 +201,7 @@ static void collectstring (lua_State *L, int limit) { static void markall (lua_State *L) { travstack(L); /* mark stack objects */ - travglobal(L); /* mark global variable values and names */ + hashmark(L, L->gt); /* mark global variable values and names */ travlock(L); /* mark locked objects */ luaT_travtagmethods(L, markobject); /* mark tag methods */ } -- cgit v1.2.3-55-g6feb