瀏覽代碼

other distribution of memory debug information.

Roberto Ierusalimschy 28 年之前
父節點
當前提交
00c122cc29
共有 3 個文件被更改,包括 15 次插入15 次删除
  1. 9 2
      lbuiltin.c
  2. 3 11
      lmem.c
  3. 3 2
      lmem.h

+ 9 - 2
lbuiltin.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lbuiltin.c,v 1.12 1997/11/27 18:25:14 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.13 1997/11/28 12:39:45 roberto Exp roberto $
 ** Built-in functions
 ** See Copyright Notice in lua.h
 */
@@ -373,6 +373,13 @@ static void luaI_collectgarbage (void)
 */
 #ifdef DEBUG
 
+static void mem_query (void)
+{
+  lua_pushnumber(totalmem);
+  lua_pushnumber(numblocks);
+}
+
+
 static void testC (void)
 {
 #define getnum(s)	((*s++) - '0')
@@ -433,7 +440,7 @@ static struct luaL_reg int_funcs[] = {
 #endif
 #ifdef DEBUG
   {"testC", testC},
-  {"totalmem", luaM_query},
+  {"totalmem", mem_query},
 #endif
   {"assert", luaI_assert},
   {"call", luaI_call},

+ 3 - 11
lmem.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lmem.c,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
+** $Id: lmem.c,v 1.2 1997/11/19 17:29:23 roberto Exp roberto $
 ** Interface to Memory Manager
 ** See Copyright Notice in lua.h
 */
@@ -80,16 +80,8 @@ void *luaM_realloc (void *block, unsigned long size)
 
 #define MARK    55
 
-static unsigned long numblocks = 0;
-static unsigned long totalmem = 0;
-
-
-
-void luaM_query (void)
-{
-  lua_pushnumber(totalmem);
-  lua_pushnumber(numblocks);
-}
+unsigned long numblocks = 0;
+unsigned long totalmem = 0;
 
 
 static void *checkblock (void *block)

+ 3 - 2
lmem.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lmem.h,v 1.2 1997/11/26 18:53:45 roberto Exp roberto $
+** $Id: lmem.h,v 1.3 1997/11/26 20:44:52 roberto Exp roberto $
 ** Interface to Memory Manager
 ** See Copyright Notice in lua.h
 */
@@ -36,7 +36,8 @@ int luaM_growaux (void **block, unsigned long nelems, int size,
 
 
 #ifdef DEBUG
-void luaM_query (void);
+extern unsigned long numblocks;
+extern unsigned long totalmem;
 #endif