diff options
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 1.1 1997/11/19 17:31:19 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.2 1997/11/27 15:59:25 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,6 +7,8 @@ | |||
7 | 7 | ||
8 | #include "lbuiltin.h" | 8 | #include "lbuiltin.h" |
9 | #include "ldo.h" | 9 | #include "ldo.h" |
10 | #include "lfunc.h" | ||
11 | #include "lgc.h" | ||
10 | #include "llex.h" | 12 | #include "llex.h" |
11 | #include "lmem.h" | 13 | #include "lmem.h" |
12 | #include "lstate.h" | 14 | #include "lstate.h" |
@@ -48,3 +50,27 @@ void lua_open (void) | |||
48 | luaB_predefine(); | 50 | luaB_predefine(); |
49 | } | 51 | } |
50 | 52 | ||
53 | |||
54 | void lua_close (void) | ||
55 | { | ||
56 | TaggedString *alludata = luaS_collectudata(); | ||
57 | L->GCthreshold = MAX_INT; /* to avoid GC during GC */ | ||
58 | luaC_hashcallIM((Hash *)L->roottable.next); /* GC t.methods for tables */ | ||
59 | luaC_strcallIM(alludata); /* GC tag methods for userdata */ | ||
60 | luaD_gcIM(&luaO_nilobject); /* GC tag method for nil (signal end of GC) */ | ||
61 | luaH_free((Hash *)L->roottable.next); | ||
62 | luaF_freeproto((TProtoFunc *)L->rootproto.next); | ||
63 | luaF_freeclosure((Closure *)L->rootcl.next); | ||
64 | luaS_free(alludata); | ||
65 | luaS_freeall(); | ||
66 | luaM_free(L->stack.stack); | ||
67 | luaM_free(L->IMtable); | ||
68 | luaM_free(L->refArray); | ||
69 | luaM_free(L->Mbuffer); | ||
70 | luaM_free(L); | ||
71 | L = NULL; | ||
72 | #if DEBUG | ||
73 | printf("total de blocos: %ld\n", numblocks); | ||
74 | printf("total de memoria: %ld\n", totalmem); | ||
75 | #endif | ||
76 | } | ||