浏览代码

new constants LUA_NOREF and LUA_REFNIL.

Roberto Ierusalimschy 26 年之前
父节点
当前提交
b44e35b773
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 3 3
      lgc.c
  2. 4 1
      lua.h

+ 3 - 3
lgc.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.c,v 1.22 1999/02/26 15:48:55 roberto Exp roberto $
+** $Id: lgc.c,v 1.23 1999/03/04 21:17:26 roberto Exp roberto $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -32,7 +32,7 @@ static int markobject (TObject *o);
 int luaC_ref (TObject *o, int lock) {
   int ref;
   if (ttype(o) == LUA_T_NIL)
-    ref = -1;   /* special ref for nil */
+    ref = LUA_REFNIL;
   else {
     for (ref=0; ref<L->refSize; ref++)
       if (L->refArray[ref].status == FREE)
@@ -57,7 +57,7 @@ void lua_unref (int ref)
 
 TObject* luaC_getref (int ref)
 {
-  if (ref == -1)
+  if (ref == LUA_REFNIL)
     return &luaO_nilobject;
   if (ref >= 0 && ref < L->refSize &&
       (L->refArray[ref].status == LOCK || L->refArray[ref].status == HOLD))

+ 4 - 1
lua.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lua.h,v 1.31 1999/04/15 12:33:19 roberto Exp roberto $
+** $Id: lua.h,v 1.32 1999/05/11 20:29:19 roberto Exp roberto $
 ** Lua - An Extensible Extension Language
 ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
 ** e-mail: [email protected]
@@ -18,6 +18,9 @@
 
 #define LUA_NOOBJECT  0
 
+#define LUA_NOREF	(-2)
+#define LUA_REFNIL	(-1)
+
 #define LUA_ANYTAG    (-1)
 
 typedef struct lua_State lua_State;