MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaB_collectgarbage

Function luaB_collectgarbage

extlibs/lua/src/lbaselib.c:190–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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