diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-10-04 15:51:04 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-10-04 15:51:04 -0200 |
| commit | 4343420d4d559a7d4cdacdbc1fd61552dcf59f04 (patch) | |
| tree | 57e0bdd41e2f3a4ab70d3150022569751e3d02ad /lstate.c | |
| parent | 1f7103e05d01a6a4c300a73bcfc8d9b17b2c20a4 (diff) | |
| download | lua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.tar.gz lua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.tar.bz2 lua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.zip | |
simplified version of `gc' tag method (only for userdata now).
Diffstat (limited to 'lstate.c')
| -rw-r--r-- | lstate.c | 27 |
1 files changed, 7 insertions, 20 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 1.12 1999/05/11 20:08:20 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.13 1999/08/16 20:52:00 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,13 +7,11 @@ | |||
| 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 "lgc.h" |
| 12 | #include "llex.h" | 11 | #include "llex.h" |
| 13 | #include "lmem.h" | 12 | #include "lmem.h" |
| 14 | #include "lstate.h" | 13 | #include "lstate.h" |
| 15 | #include "lstring.h" | 14 | #include "lstring.h" |
| 16 | #include "ltable.h" | ||
| 17 | #include "ltm.h" | 15 | #include "ltm.h" |
| 18 | 16 | ||
| 19 | 17 | ||
| @@ -36,14 +34,10 @@ void lua_open (void) { | |||
| 36 | L->debug = 0; | 34 | L->debug = 0; |
| 37 | L->callhook = NULL; | 35 | L->callhook = NULL; |
| 38 | L->linehook = NULL; | 36 | L->linehook = NULL; |
| 39 | L->rootproto.next = NULL; | 37 | L->rootproto = NULL; |
| 40 | L->rootproto.marked = 0; | 38 | L->rootcl = NULL; |
| 41 | L->rootcl.next = NULL; | 39 | L->rootglobal = NULL; |
| 42 | L->rootcl.marked = 0; | 40 | L->roottable = NULL; |
| 43 | L->rootglobal.next = NULL; | ||
| 44 | L->rootglobal.marked = 0; | ||
| 45 | L->roottable.next = NULL; | ||
| 46 | L->roottable.marked = 0; | ||
| 47 | L->IMtable = NULL; | 41 | L->IMtable = NULL; |
| 48 | L->refArray = NULL; | 42 | L->refArray = NULL; |
| 49 | L->refSize = 0; | 43 | L->refSize = 0; |
| @@ -58,21 +52,14 @@ void lua_open (void) { | |||
| 58 | 52 | ||
| 59 | 53 | ||
| 60 | void lua_close (void) { | 54 | void lua_close (void) { |
| 61 | TaggedString *alludata = luaS_collectudata(); | 55 | luaC_collect(1); /* collect all elements */ |
| 62 | L->GCthreshold = MAX_INT; /* to avoid GC during GC */ | ||
| 63 | luaC_hashcallIM((Hash *)L->roottable.next); /* GC t.methods for tables */ | ||
| 64 | luaC_strcallIM(alludata); /* GC tag methods for userdata */ | ||
| 65 | luaD_gcIM(&luaO_nilobject); /* GC tag method for nil (signal end of GC) */ | ||
| 66 | luaH_free((Hash *)L->roottable.next); | ||
| 67 | luaF_freeproto((TProtoFunc *)L->rootproto.next); | ||
| 68 | luaF_freeclosure((Closure *)L->rootcl.next); | ||
| 69 | luaS_free(alludata); | ||
| 70 | luaS_freeall(); | 56 | luaS_freeall(); |
| 71 | luaM_free(L->stack.stack); | 57 | luaM_free(L->stack.stack); |
| 72 | luaM_free(L->IMtable); | 58 | luaM_free(L->IMtable); |
| 73 | luaM_free(L->refArray); | 59 | luaM_free(L->refArray); |
| 74 | luaM_free(L->Mbuffer); | 60 | luaM_free(L->Mbuffer); |
| 75 | luaM_free(L->Cblocks); | 61 | luaM_free(L->Cblocks); |
| 62 | LUA_ASSERT(L->nblocks == 0, "wrong count for nblocks"); | ||
| 76 | luaM_free(L); | 63 | luaM_free(L); |
| 77 | L = NULL; | 64 | L = NULL; |
| 78 | #ifdef DEBUG | 65 | #ifdef DEBUG |
