aboutsummaryrefslogtreecommitdiff
path: root/lfunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lfunc.c')
-rw-r--r--lfunc.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lfunc.c b/lfunc.c
index 7270e980..2ab76335 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.4 1997/10/23 16:26:37 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $
3** Lua Funcion auxiliar 3** Lua Funcion auxiliar
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -9,20 +9,18 @@
9 9
10#include "lfunc.h" 10#include "lfunc.h"
11#include "lmem.h" 11#include "lmem.h"
12#include "lstate.h"
12 13
13#define gcsizeproto(p) 5 14#define gcsizeproto(p) 5
14#define gcsizeclosure(c) 1 15#define gcsizeclosure(c) 1
15 16
16GCnode luaF_root = {NULL, 0};
17GCnode luaF_rootcl = {NULL, 0};
18
19 17
20 18
21Closure *luaF_newclosure (int nelems) 19Closure *luaF_newclosure (int nelems)
22{ 20{
23 Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject)); 21 Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject));
24 luaO_insertlist(&luaF_rootcl, (GCnode *)c); 22 luaO_insertlist(&(L->rootcl), (GCnode *)c);
25 luaO_nblocks += gcsizeclosure(c); 23 L->nblocks += gcsizeclosure(c);
26 c->nelems = nelems; 24 c->nelems = nelems;
27 return c; 25 return c;
28} 26}
@@ -46,8 +44,8 @@ TProtoFunc *luaF_newproto (void)
46 f->consts = NULL; 44 f->consts = NULL;
47 f->nconsts = 0; 45 f->nconsts = 0;
48 f->locvars = NULL; 46 f->locvars = NULL;
49 luaO_insertlist(&luaF_root, (GCnode *)f); 47 luaO_insertlist(&(L->rootproto), (GCnode *)f);
50 luaO_nblocks += gcsizeproto(f); 48 L->nblocks += gcsizeproto(f);
51 return f; 49 return f;
52} 50}
53 51
@@ -66,7 +64,7 @@ void luaF_freeproto (TProtoFunc *l)
66{ 64{
67 while (l) { 65 while (l) {
68 TProtoFunc *next = (TProtoFunc *)l->head.next; 66 TProtoFunc *next = (TProtoFunc *)l->head.next;
69 luaO_nblocks -= gcsizeproto(l); 67 L->nblocks -= gcsizeproto(l);
70 freefunc(l); 68 freefunc(l);
71 l = next; 69 l = next;
72 } 70 }
@@ -77,7 +75,7 @@ void luaF_freeclosure (Closure *l)
77{ 75{
78 while (l) { 76 while (l) {
79 Closure *next = (Closure *)l->head.next; 77 Closure *next = (Closure *)l->head.next;
80 luaO_nblocks -= gcsizeclosure(l); 78 L->nblocks -= gcsizeclosure(l);
81 luaM_free(l); 79 luaM_free(l);
82 l = next; 80 l = next;
83 } 81 }