diff options
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.82 2009/12/10 18:21:28 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.83 2009/12/11 19:14:59 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -92,8 +92,7 @@ static int tpanic (lua_State *L) { | |||
92 | #define fillmem(mem,size) /* empty */ | 92 | #define fillmem(mem,size) /* empty */ |
93 | #endif | 93 | #endif |
94 | 94 | ||
95 | 95 | Memcontrol l_memcontrol = {0L, 0L, 0L, 0L, {0L, 0L, 0L, 0L, 0L}}; | |
96 | Memcontrol l_memcontrol = {0L, 0L, 0L, 0L}; | ||
97 | 96 | ||
98 | 97 | ||
99 | static void *checkblock (void *block, size_t size) { | 98 | static void *checkblock (void *block, size_t size) { |
@@ -119,6 +118,11 @@ static void freeblock (Memcontrol *mc, void *block, size_t size) { | |||
119 | 118 | ||
120 | void *debug_realloc (void *ud, void *block, size_t oldsize, size_t size) { | 119 | void *debug_realloc (void *ud, void *block, size_t oldsize, size_t size) { |
121 | Memcontrol *mc = cast(Memcontrol *, ud); | 120 | Memcontrol *mc = cast(Memcontrol *, ud); |
121 | if (block == NULL) { | ||
122 | if (LUA_TSTRING <= oldsize && oldsize <= LUA_TTHREAD) | ||
123 | mc->objcount[oldsize - LUA_TSTRING]++; | ||
124 | oldsize = 0; | ||
125 | } | ||
122 | lua_assert((oldsize == 0) ? block == NULL : | 126 | lua_assert((oldsize == 0) ? block == NULL : |
123 | block && checkblocksize(block, oldsize)); | 127 | block && checkblocksize(block, oldsize)); |
124 | if (mc->memlimit == 0) { /* first time? */ | 128 | if (mc->memlimit == 0) { /* first time? */ |
@@ -506,10 +510,12 @@ static int get_limits (lua_State *L) { | |||
506 | 510 | ||
507 | static int mem_query (lua_State *L) { | 511 | static int mem_query (lua_State *L) { |
508 | if (lua_isnone(L, 1)) { | 512 | if (lua_isnone(L, 1)) { |
513 | int i; | ||
509 | lua_pushinteger(L, l_memcontrol.total); | 514 | lua_pushinteger(L, l_memcontrol.total); |
510 | lua_pushinteger(L, l_memcontrol.numblocks); | 515 | lua_pushinteger(L, l_memcontrol.numblocks); |
511 | lua_pushinteger(L, l_memcontrol.maxmem); | 516 | lua_pushinteger(L, l_memcontrol.maxmem); |
512 | return 3; | 517 | for (i = 0; i < 5; i++) lua_pushinteger(L, l_memcontrol.objcount[i]); |
518 | return 3 + 5; | ||
513 | } | 519 | } |
514 | else { | 520 | else { |
515 | l_memcontrol.memlimit = luaL_checkint(L, 1); | 521 | l_memcontrol.memlimit = luaL_checkint(L, 1); |