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

Function luaB_collectgarbage

engine/lua/src/lua/lbaselib.c:193–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192
193static int luaB_collectgarbage (lua_State *L) {
194 static const char *const opts[] = {"stop", "restart", "collect",
195 "count", "step", "setpause", "setstepmul", NULL};
196 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
197 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL};
198 int o = luaL_checkoption(L, 1, "collect", opts);
199 int ex = luaL_optint(L, 2, 0);
200 int res = lua_gc(L, optsnum[o], ex);
201 switch (optsnum[o]) {
202 case LUA_GCCOUNT: {
203 int b = lua_gc(L, LUA_GCCOUNTB, 0);
204 lua_pushnumber(L, res + ((lua_Number)b/1024));
205 return 1;
206 }
207 case LUA_GCSTEP: {
208 lua_pushboolean(L, res);
209 return 1;
210 }
211 default: {
212 lua_pushnumber(L, res);
213 return 1;
214 }
215 }
216}
217
218
219static int luaB_type (lua_State *L) {

Callers

nothing calls this directly

Calls 4

luaL_checkoptionFunction · 0.85
lua_gcFunction · 0.85
lua_pushnumberFunction · 0.85
lua_pushbooleanFunction · 0.85

Tested by

no test coverage detected