diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-12-01 16:22:56 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-12-01 16:22:56 -0200 |
commit | af850484a9e01b46b04e4c666f9a9e91308d81c7 (patch) | |
tree | 38d03f647ddc95d430e4600e432598b7b9d07cd0 /lgc.c | |
parent | 1d10acb35500df47d6052164e6c56476f520232e (diff) | |
download | lua-af850484a9e01b46b04e4c666f9a9e91308d81c7.tar.gz lua-af850484a9e01b46b04e4c666f9a9e91308d81c7.tar.bz2 lua-af850484a9e01b46b04e4c666f9a9e91308d81c7.zip |
default metatable can be NULL
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.180 2003/11/19 19:41:57 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.181 2003/12/01 16:33:30 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -114,8 +114,9 @@ static void reallymarkobject (global_State *g, GCObject *o) { | |||
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | case LUA_TUSERDATA: { | 116 | case LUA_TUSERDATA: { |
117 | Table *mt = gcotou(o)->uv.metatable; | ||
117 | white2black(o); /* userdata do not go to gray list */ | 118 | white2black(o); /* userdata do not go to gray list */ |
118 | markobject(g, gcotou(o)->uv.metatable); | 119 | if (mt) markobject(g, mt); |
119 | return; | 120 | return; |
120 | } | 121 | } |
121 | case LUA_TFUNCTION: { | 122 | case LUA_TFUNCTION: { |
@@ -191,7 +192,8 @@ static void traversetable (global_State *g, Table *h) { | |||
191 | int weakkey = 0; | 192 | int weakkey = 0; |
192 | int weakvalue = 0; | 193 | int weakvalue = 0; |
193 | const TObject *mode; | 194 | const TObject *mode; |
194 | markobject(g, h->metatable); | 195 | if (h->metatable) |
196 | markobject(g, h->metatable); | ||
195 | lua_assert(h->lsizenode || h->node == g->dummynode); | 197 | lua_assert(h->lsizenode || h->node == g->dummynode); |
196 | mode = gfasttm(g, h->metatable, TM_MODE); | 198 | mode = gfasttm(g, h->metatable, TM_MODE); |
197 | if (mode && ttisstring(mode)) { /* is there a weak mode? */ | 199 | if (mode && ttisstring(mode)) { /* is there a weak mode? */ |
@@ -534,7 +536,6 @@ static void markroot (lua_State *L) { | |||
534 | g->weak = NULL; | 536 | g->weak = NULL; |
535 | makewhite(valtogco(g->mainthread)); | 537 | makewhite(valtogco(g->mainthread)); |
536 | markobject(g, g->mainthread); | 538 | markobject(g, g->mainthread); |
537 | markvalue(g, defaultmeta(L)); | ||
538 | markvalue(g, registry(L)); | 539 | markvalue(g, registry(L)); |
539 | if (L != g->mainthread) /* another thread is running? */ | 540 | if (L != g->mainthread) /* another thread is running? */ |
540 | markobject(g, L); /* cannot collect it */ | 541 | markobject(g, L); /* cannot collect it */ |