Browse Source

code redistribution

Roberto Ierusalimschy 25 years ago
parent
commit
870f61d299
3 changed files with 16 additions and 17 deletions
  1. 1 12
      ldo.c
  2. 1 2
      ldo.h
  3. 14 3
      lgc.c

+ 1 - 12
ldo.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 1.71 2000/03/30 17:19:48 roberto Exp roberto $
+** $Id: ldo.c,v 1.72 2000/03/30 20:55:50 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -326,17 +326,6 @@ static int do_main (lua_State *L, ZIO *z, int bin) {
 }
 
 
-void luaD_gcIM (lua_State *L, const TObject *o) {
-  const TObject *im = luaT_getimbyObj(L, o, IM_GC);
-  if (ttype(im) != TAG_NIL) {
-    luaD_checkstack(L, 2);
-    *(L->top++) = *im;
-    *(L->top++) = *o;
-    luaD_call(L, L->top-2, 0);
-  }
-}
-
-
 #define	MAXFILENAME	260	/* maximum part of a file name kept */
 
 int lua_dofile (lua_State *L, const char *filename) {

+ 1 - 2
ldo.h

@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.h,v 1.18 2000/03/24 17:26:08 roberto Exp roberto $
+** $Id: ldo.h,v 1.19 2000/03/29 20:19:20 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -26,7 +26,6 @@ void luaD_lineHook (lua_State *L, StkId func, int line);
 void luaD_call (lua_State *L, StkId func, int nResults);
 void luaD_callTM (lua_State *L, const TObject *f, int nParams, int nResults);
 int luaD_protectedrun (lua_State *L);
-void luaD_gcIM (lua_State *L, const TObject *o);
 void luaD_checkstack (lua_State *L, int n);
 
 

+ 14 - 3
lgc.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.c,v 1.45 2000/03/29 20:19:20 roberto Exp roberto $
+** $Id: lgc.c,v 1.46 2000/03/30 20:55:50 roberto Exp roberto $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -20,6 +20,17 @@
 
 
 
+static void luaD_gcTM (lua_State *L, const TObject *o) {
+  const TObject *im = luaT_getimbyObj(L, o, IM_GC);
+  if (ttype(im) != TAG_NIL) {
+    luaD_checkstack(L, 2);
+    *(L->top++) = *im;
+    *(L->top++) = *o;
+    luaD_call(L, L->top-2, 0);
+  }
+}
+
+
 static int markobject (lua_State *L, TObject *o);
 
 
@@ -201,7 +212,7 @@ static void collectstring (lua_State *L, int limit) {
        else {  /* collect */
           if (next->constindex == -1) {  /* is userdata? */
             tsvalue(&o) = next;
-            luaD_gcIM(L, &o);
+            luaD_gcTM(L, &o);
           }
           *p = next->nexthash;
           luaS_free(L, next);
@@ -240,13 +251,13 @@ long lua_collectgarbage (lua_State *L, long limit) {
   markall(L);
   luaR_invalidaterefs(L);
   luaC_collect(L, 0);
-  luaD_gcIM(L, &luaO_nilobject);  /* GC tag method for nil (signal end of GC) */
   recovered = recovered - L->nblocks;
   L->GCthreshold = (limit == 0) ? 2*L->nblocks : L->nblocks+limit;
   if (L->Mbuffsize > L->Mbuffnext*4) {  /* is buffer too big? */
     L->Mbuffsize /= 2;  /* still larger than Mbuffnext*2 */
     luaM_reallocvector(L, L->Mbuffer, L->Mbuffsize, char);
   }
+  luaD_gcTM(L, &luaO_nilobject);
   return recovered;
 }