From 345379b5ff7ce6f5a732a6954bfb5e83bce12036 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 4 Jun 2004 12:30:53 -0300 Subject: option for garbage-collector `step' --- lbaselib.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index a4c3db6f..aa9a6f1e 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.144 2004/05/31 18:50:30 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.145 2004/06/02 14:20:08 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -180,22 +180,11 @@ static int luaB_gcinfo (lua_State *L) { static int luaB_collectgarbage (lua_State *L) { static const char *const opts[] = {"stop", "restart", "collect", "count", - NULL}; + "step", NULL}; static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, - LUA_GCCOLLECT, LUA_GCCOUNT}; - int o; - int ex; -#if 1 - if (lua_isnumber(L, 1)) { - int v = lua_tointeger(L, 1); - lua_settop(L, 0); - if (v == 0) lua_pushstring(L, "collect"); - else if (v >= 10000) lua_pushstring(L, "stop"); - else lua_pushstring(L, "restart"); - } -#endif - o = luaL_findstring(luaL_optstring(L, 1, "collect"), opts); - ex = luaL_optint(L, 2, 0); + LUA_GCCOLLECT, LUA_GCCOUNT, LUA_GCSTEP}; + int o = luaL_findstring(luaL_optstring(L, 1, "collect"), opts); + int ex = luaL_optint(L, 2, 0); luaL_argcheck(L, o >= 0, 1, "invalid option"); lua_pushinteger(L, lua_gc(L, optsnum[o], ex)); return 1; -- cgit v1.2.3-55-g6feb