diff options
Diffstat (limited to 'lfunc.c')
-rw-r--r-- | lfunc.c | 34 |
1 files changed, 12 insertions, 22 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 1.10 1999/03/04 21:17:26 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 1.11 1999/08/16 20:52:00 roberto Exp roberto $ |
3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -18,7 +18,9 @@ | |||
18 | 18 | ||
19 | Closure *luaF_newclosure (int nelems) { | 19 | Closure *luaF_newclosure (int nelems) { |
20 | Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject)); | 20 | Closure *c = (Closure *)luaM_malloc(sizeof(Closure)+nelems*sizeof(TObject)); |
21 | luaO_insertlist(&(L->rootcl), (GCnode *)c); | 21 | c->next = L->rootcl; |
22 | L->rootcl = c; | ||
23 | c->marked = 0; | ||
22 | L->nblocks += gcsizeclosure(c); | 24 | L->nblocks += gcsizeclosure(c); |
23 | c->nelems = nelems; | 25 | c->nelems = nelems; |
24 | return c; | 26 | return c; |
@@ -33,14 +35,16 @@ TProtoFunc *luaF_newproto (void) { | |||
33 | f->consts = NULL; | 35 | f->consts = NULL; |
34 | f->nconsts = 0; | 36 | f->nconsts = 0; |
35 | f->locvars = NULL; | 37 | f->locvars = NULL; |
36 | luaO_insertlist(&(L->rootproto), (GCnode *)f); | 38 | f->next = L->rootproto; |
39 | L->rootproto = f; | ||
40 | f->marked = 0; | ||
37 | L->nblocks += gcsizeproto(f); | 41 | L->nblocks += gcsizeproto(f); |
38 | return f; | 42 | return f; |
39 | } | 43 | } |
40 | 44 | ||
41 | 45 | ||
42 | 46 | void luaF_freeproto (TProtoFunc *f) { | |
43 | static void freefunc (TProtoFunc *f) { | 47 | L->nblocks -= gcsizeproto(f); |
44 | luaM_free(f->code); | 48 | luaM_free(f->code); |
45 | luaM_free(f->locvars); | 49 | luaM_free(f->locvars); |
46 | luaM_free(f->consts); | 50 | luaM_free(f->consts); |
@@ -48,23 +52,9 @@ static void freefunc (TProtoFunc *f) { | |||
48 | } | 52 | } |
49 | 53 | ||
50 | 54 | ||
51 | void luaF_freeproto (TProtoFunc *l) { | 55 | void luaF_freeclosure (Closure *c) { |
52 | while (l) { | 56 | L->nblocks -= gcsizeclosure(c); |
53 | TProtoFunc *next = (TProtoFunc *)l->head.next; | 57 | luaM_free(c); |
54 | L->nblocks -= gcsizeproto(l); | ||
55 | freefunc(l); | ||
56 | l = next; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | |||
61 | void luaF_freeclosure (Closure *l) { | ||
62 | while (l) { | ||
63 | Closure *next = (Closure *)l->head.next; | ||
64 | L->nblocks -= gcsizeclosure(l); | ||
65 | luaM_free(l); | ||
66 | l = next; | ||
67 | } | ||
68 | } | 58 | } |
69 | 59 | ||
70 | 60 | ||