lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Making it display bytes now could break a lot of existing code, but
> it's pretty easy to mod the code to add your own option...

For instance, collectgarbage("count") could return two values: one in K
and one in bytes. The change is simple:

lbaselib.c:
static int luaB_collectgarbage (lua_State *L) {
...
    case LUA_GCCOUNT: {
      int b = lua_gc(L, LUA_GCCOUNTB, 0);
      lua_pushnumber(L, res + ((lua_Number)b/1024));
      lua_pushnumber(L, res*1024 + b);			<<<
      return 2;						<<<
    }