better way to traverse GCnode lists.

This commit is contained in:
Roberto Ierusalimschy
1997-09-26 13:46:20 -03:00
parent a580480b07
commit eb617df2d8
7 changed files with 40 additions and 55 deletions

21
lfunc.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: $
** $Id: lfunc.c,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
** Lua Funcion auxiliar
** See Copyright Notice in lua.h
*/
@@ -11,26 +11,15 @@
#include "lmem.h"
TProtoFunc *luaF_root = NULL;
Closure *luaF_rootcl = NULL;
GCnode luaF_root = {NULL, 0};
GCnode luaF_rootcl = {NULL, 0};
static void luaI_insertfunction (TProtoFunc *f)
{
++luaO_nentities;
f->head.next = (GCnode *)luaF_root;
luaF_root = f;
f->head.marked = 0;
}
Closure *luaF_newclosure (int nelems)
{
Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject));
++luaO_nentities;
c->head.next = (GCnode *)luaF_rootcl;
luaF_rootcl = c;
c->head.marked = 0;
luaO_insertlist(&luaF_rootcl, (GCnode *)c);
return c;
}
@@ -45,7 +34,7 @@ TProtoFunc *luaF_newproto (void)
f->nconsts = 0;
f->nupvalues = 0;
f->locvars = NULL;
luaI_insertfunction(f);
luaO_insertlist(&luaF_root, (GCnode *)f);
return f;
}