simplified version of `gc' tag method (only for userdata now).

This commit is contained in:
Roberto Ierusalimschy
1999-10-04 15:51:04 -02:00
parent 1f7103e05d
commit 4343420d4d
20 changed files with 384 additions and 443 deletions

34
lfunc.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lfunc.c,v 1.10 1999/03/04 21:17:26 roberto Exp roberto $
** $Id: lfunc.c,v 1.11 1999/08/16 20:52:00 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@@ -18,7 +18,9 @@
Closure *luaF_newclosure (int nelems) {
Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject));
luaO_insertlist(&(L->rootcl), (GCnode *)c);
c->next = L->rootcl;
L->rootcl = c;
c->marked = 0;
L->nblocks += gcsizeclosure(c);
c->nelems = nelems;
return c;
@@ -33,14 +35,16 @@ TProtoFunc *luaF_newproto (void) {
f->consts = NULL;
f->nconsts = 0;
f->locvars = NULL;
luaO_insertlist(&(L->rootproto), (GCnode *)f);
f->next = L->rootproto;
L->rootproto = f;
f->marked = 0;
L->nblocks += gcsizeproto(f);
return f;
}
static void freefunc (TProtoFunc *f) {
void luaF_freeproto (TProtoFunc *f) {
L->nblocks -= gcsizeproto(f);
luaM_free(f->code);
luaM_free(f->locvars);
luaM_free(f->consts);
@@ -48,23 +52,9 @@ static void freefunc (TProtoFunc *f) {
}
void luaF_freeproto (TProtoFunc *l) {
while (l) {
TProtoFunc *next = (TProtoFunc *)l->head.next;
L->nblocks -= gcsizeproto(l);
freefunc(l);
l = next;
}
}
void luaF_freeclosure (Closure *l) {
while (l) {
Closure *next = (Closure *)l->head.next;
L->nblocks -= gcsizeclosure(l);
luaM_free(l);
l = next;
}
void luaF_freeclosure (Closure *c) {
L->nblocks -= gcsizeclosure(c);
luaM_free(c);
}