aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-01-16 17:02:55 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-01-16 17:02:55 -0300
commit4a8e48086433ad12f2991c07f3064278714fd0f1 (patch)
tree7efc32733ceff1ce51930d927292e7b7ce56b175 /lbaselib.c
parent17e0c29d9b435392016b707309ed51409b0aea12 (diff)
downloadlua-4a8e48086433ad12f2991c07f3064278714fd0f1.tar.gz
lua-4a8e48086433ad12f2991c07f3064278714fd0f1.tar.bz2
lua-4a8e48086433ad12f2991c07f3064278714fd0f1.zip
New mechanism to query GC parameters
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 25dcaf52..4238f96a 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -199,10 +199,10 @@ static int pushmode (lua_State *L, int oldmode) {
199static int luaB_collectgarbage (lua_State *L) { 199static int luaB_collectgarbage (lua_State *L) {
200 static const char *const opts[] = {"stop", "restart", "collect", 200 static const char *const opts[] = {"stop", "restart", "collect",
201 "count", "step", "isrunning", "generational", "incremental", 201 "count", "step", "isrunning", "generational", "incremental",
202 "setparam", NULL}; 202 "param", NULL};
203 static const char optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, 203 static const char optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
204 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC, 204 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC,
205 LUA_GCSETPARAM}; 205 LUA_GCPARAM};
206 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; 206 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
207 switch (o) { 207 switch (o) {
208 case LUA_GCCOUNT: { 208 case LUA_GCCOUNT: {
@@ -231,7 +231,7 @@ static int luaB_collectgarbage (lua_State *L) {
231 case LUA_GCINC: { 231 case LUA_GCINC: {
232 return pushmode(L, lua_gc(L, o)); 232 return pushmode(L, lua_gc(L, o));
233 } 233 }
234 case LUA_GCSETPARAM: { 234 case LUA_GCPARAM: {
235 static const char *const params[] = { 235 static const char *const params[] = {
236 "minormul", "majorminor", "minormajor", 236 "minormul", "majorminor", "minormajor",
237 "pause", "stepmul", "stepsize", NULL}; 237 "pause", "stepmul", "stepsize", NULL};
@@ -239,7 +239,7 @@ static int luaB_collectgarbage (lua_State *L) {
239 LUA_GCPMINORMUL, LUA_GCPMAJORMINOR, LUA_GCPMINORMAJOR, 239 LUA_GCPMINORMUL, LUA_GCPMAJORMINOR, LUA_GCPMINORMAJOR,
240 LUA_GCPPAUSE, LUA_GCPSTEPMUL, LUA_GCPSTEPSIZE}; 240 LUA_GCPPAUSE, LUA_GCPSTEPMUL, LUA_GCPSTEPSIZE};
241 int p = pnum[luaL_checkoption(L, 2, NULL, params)]; 241 int p = pnum[luaL_checkoption(L, 2, NULL, params)];
242 lua_Integer value = luaL_checkinteger(L, 3); 242 lua_Integer value = luaL_optinteger(L, 3, -1);
243 lua_pushinteger(L, lua_gc(L, o, p, (int)value)); 243 lua_pushinteger(L, lua_gc(L, o, p, (int)value));
244 return 1; 244 return 1;
245 } 245 }