diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.183 2005/09/16 18:22:48 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.184 2005/10/03 14:36:45 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -196,9 +196,23 @@ static int luaB_collectgarbage (lua_State *L) { | |||
196 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, | 196 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, |
197 | LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; | 197 | LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; |
198 | int o = luaL_checkoption(L, 1, "collect", opts); | 198 | int o = luaL_checkoption(L, 1, "collect", opts); |
199 | int ex = luaL_optinteger(L, 2, 0); | 199 | int ex = luaL_optint(L, 2, 0); |
200 | lua_pushinteger(L, lua_gc(L, optsnum[o], ex)); | 200 | int res = lua_gc(L, optsnum[o], ex); |
201 | return 1; | 201 | switch (optsnum[o]) { |
202 | case LUA_GCCOUNT: { | ||
203 | int b = lua_gc(L, LUA_GCCOUNTB, 0); | ||
204 | lua_pushnumber(L, ((lua_Number)res*1024 + b)/1000); | ||
205 | return 1; | ||
206 | } | ||
207 | case LUA_GCSTEP: { | ||
208 | lua_pushboolean(L, res); | ||
209 | return 1; | ||
210 | } | ||
211 | default: { | ||
212 | lua_pushnumber(L, res); | ||
213 | return 1; | ||
214 | } | ||
215 | } | ||
202 | } | 216 | } |
203 | 217 | ||
204 | 218 | ||