aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-11-03 18:45:23 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-11-03 18:45:23 -0200
commit7135803cc87fafe80494bdc094613515487410b9 (patch)
tree439f9c6f1173707f7e37520c550e48edb5cafab8 /lgc.c
parentb7567b667367180b75fbb60f7a73b75e5e89889e (diff)
downloadlua-7135803cc87fafe80494bdc094613515487410b9.tar.gz
lua-7135803cc87fafe80494bdc094613515487410b9.tar.bz2
lua-7135803cc87fafe80494bdc094613515487410b9.zip
"global" version of a nil object.
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/lgc.c b/lgc.c
index aafc4cb8..6fdbacaa 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.5 1997/10/23 16:26:37 roberto Exp roberto $ 2** $Id: lgc.c,v 1.6 1997/10/24 17:17:24 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*/
@@ -66,9 +66,8 @@ void lua_unref (int ref)
66 66
67TObject* luaC_getref (int ref) 67TObject* luaC_getref (int ref)
68{ 68{
69 static TObject nul = {LUA_T_NIL, {0}};
70 if (ref == -1) 69 if (ref == -1)
71 return &nul; 70 return &luaO_nilobject;
72 if (ref >= 0 && ref < refSize && 71 if (ref >= 0 && ref < refSize &&
73 (refArray[ref].status == LOCK || refArray[ref].status == HOLD)) 72 (refArray[ref].status == LOCK || refArray[ref].status == HOLD))
74 return &refArray[ref].o; 73 return &refArray[ref].o;
@@ -240,14 +239,6 @@ static int markobject (TObject *o)
240} 239}
241 240
242 241
243static void call_nilIM (void)
244{ /* signals end of garbage collection */
245 TObject t;
246 ttype(&t) = LUA_T_NIL;
247 luaD_gcIM(&t); /* end of list */
248}
249
250
251 242
252#define GARBAGE_BLOCK 150 243#define GARBAGE_BLOCK 150
253 244
@@ -279,7 +270,7 @@ long lua_collectgarbage (long limit)
279 luaC_threshold *= 4; /* to avoid GC during GC */ 270 luaC_threshold *= 4; /* to avoid GC during GC */
280 hashcallIM(freetable); /* GC tag methods for tables */ 271 hashcallIM(freetable); /* GC tag methods for tables */
281 strcallIM(freestr); /* GC tag methods for userdata */ 272 strcallIM(freestr); /* GC tag methods for userdata */
282 call_nilIM(); /* GC tag method for nil (signal end of GC) */ 273 luaD_gcIM(&luaO_nilobject); /* GC tag method for nil (signal end of GC) */
283 luaH_free(freetable); 274 luaH_free(freetable);
284 luaS_free(freestr); 275 luaS_free(freestr);
285 luaF_freeproto(freefunc); 276 luaF_freeproto(freefunc);