collect dead indices in tables

This commit is contained in:
Roberto Ierusalimschy
2000-06-05 17:07:53 -03:00
parent dbfb810267
commit c542aac0b9
3 changed files with 28 additions and 3 deletions

4
lgc.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 1.53 2000/05/30 19:00:31 roberto Exp roberto $
** $Id: lgc.c,v 1.54 2000/06/05 14:56:18 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -64,6 +64,8 @@ static void tablemark (lua_State *L, Hash *h) {
for (i=h->size-1; i>=0; i--) {
Node *n = node(h,i);
if (ttype(key(n)) != TAG_NIL) {
if (ttype(val(n)) == TAG_NIL)
luaH_remove(h, key(n)); /* dead element; try to remove it */
markobject(L, &n->key);
markobject(L, &n->val);
}