diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-12-27 12:09:11 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-12-27 12:09:11 -0300 |
commit | 12b6f610b0f1b4157c04f0db264f1f1d0634709b (patch) | |
tree | 198881cf4ac938aa9082fe7781d575e359d9bf09 /lbaselib.c | |
parent | e81f586001d767c8de9b760ae2e2c3b5da1542c6 (diff) | |
download | lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.tar.gz lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.tar.bz2 lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.zip |
Several tweaks in the garbage collector
- back with step size in collectgarbage("step")
- adjustments in defaults for some GC parameters
- adjustments in 'luaO_codeparam'
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -213,7 +213,8 @@ static int luaB_collectgarbage (lua_State *L) { | |||
213 | return 1; | 213 | return 1; |
214 | } | 214 | } |
215 | case LUA_GCSTEP: { | 215 | case LUA_GCSTEP: { |
216 | int res = lua_gc(L, o); | 216 | lua_Integer n = luaL_optinteger(L, 2, 0); |
217 | int res = lua_gc(L, o, (int)n); | ||
217 | checkvalres(res); | 218 | checkvalres(res); |
218 | lua_pushboolean(L, res); | 219 | lua_pushboolean(L, res); |
219 | return 1; | 220 | return 1; |
@@ -239,7 +240,7 @@ static int luaB_collectgarbage (lua_State *L) { | |||
239 | LUA_GCPPAUSE, LUA_GCPSTEPMUL, LUA_GCPSTEPSIZE}; | 240 | LUA_GCPPAUSE, LUA_GCPSTEPMUL, LUA_GCPSTEPSIZE}; |
240 | int p = pnum[luaL_checkoption(L, 2, NULL, params)]; | 241 | int p = pnum[luaL_checkoption(L, 2, NULL, params)]; |
241 | lua_Integer value = luaL_checkinteger(L, 3); | 242 | lua_Integer value = luaL_checkinteger(L, 3); |
242 | lua_pushinteger(L, lua_gc(L, o, p, value)); | 243 | lua_pushinteger(L, lua_gc(L, o, p, (int)value)); |
243 | return 1; | 244 | return 1; |
244 | } | 245 | } |
245 | default: { | 246 | default: { |
@@ -337,10 +338,7 @@ static int load_aux (lua_State *L, int status, int envidx) { | |||
337 | 338 | ||
338 | static const char *getmode (lua_State *L, int idx) { | 339 | static const char *getmode (lua_State *L, int idx) { |
339 | const char *mode = luaL_optstring(L, idx, "bt"); | 340 | const char *mode = luaL_optstring(L, idx, "bt"); |
340 | int i = 0; | 341 | if (strchr(mode, 'B') != NULL) /* Lua code cannot use fixed buffers */ |
341 | if (mode[i] == 'b') i++; | ||
342 | if (mode[i] == 't') i++; | ||
343 | if (mode[i] != '\0') | ||
344 | luaL_argerror(L, idx, "invalid mode"); | 342 | luaL_argerror(L, idx, "invalid mode"); |
345 | return mode; | 343 | return mode; |
346 | } | 344 | } |