MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaB_collectgarbage

Function luaB_collectgarbage

3rd/lua-5.4.3/src/lbaselib.c:191–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189
190
191static int luaB_collectgarbage (lua_State *L) {
192 static const char *const opts[] = {"stop", "restart", "collect",
193 "count", "step", "setpause", "setstepmul",
194 "isrunning", "generational", "incremental", NULL};
195 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
196 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
197 LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
198 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
199 switch (o) {
200 case LUA_GCCOUNT: {
201 int k = lua_gc(L, o);
202 int b = lua_gc(L, LUA_GCCOUNTB);
203 lua_pushnumber(L, (lua_Number)k + ((lua_Number)b/1024));
204 return 1;
205 }
206 case LUA_GCSTEP: {
207 int step = (int)luaL_optinteger(L, 2, 0);
208 int res = lua_gc(L, o, step);
209 lua_pushboolean(L, res);
210 return 1;
211 }
212 case LUA_GCSETPAUSE:
213 case LUA_GCSETSTEPMUL: {
214 int p = (int)luaL_optinteger(L, 2, 0);
215 int previous = lua_gc(L, o, p);
216 lua_pushinteger(L, previous);
217 return 1;
218 }
219 case LUA_GCISRUNNING: {
220 int res = lua_gc(L, o);
221 lua_pushboolean(L, res);
222 return 1;
223 }
224 case LUA_GCGEN: {
225 int minormul = (int)luaL_optinteger(L, 2, 0);
226 int majormul = (int)luaL_optinteger(L, 3, 0);
227 return pushmode(L, lua_gc(L, o, minormul, majormul));
228 }
229 case LUA_GCINC: {
230 int pause = (int)luaL_optinteger(L, 2, 0);
231 int stepmul = (int)luaL_optinteger(L, 3, 0);
232 int stepsize = (int)luaL_optinteger(L, 4, 0);
233 return pushmode(L, lua_gc(L, o, pause, stepmul, stepsize));
234 }
235 default: {
236 int res = lua_gc(L, o);
237 lua_pushinteger(L, res);
238 return 1;
239 }
240 }
241}
242
243
244static int luaB_type (lua_State *L) {

Callers

nothing calls this directly

Calls 7

luaL_checkoptionFunction · 0.85
lua_gcFunction · 0.85
lua_pushnumberFunction · 0.85
luaL_optintegerFunction · 0.85
lua_pushbooleanFunction · 0.85
lua_pushintegerFunction · 0.85
pushmodeFunction · 0.85

Tested by

no test coverage detected