MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaB_collectgarbage

Function luaB_collectgarbage

freebsd/contrib/openzfs/module/lua/lbaselib.c:142–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140
141
142static int luaB_collectgarbage (lua_State *L) {
143 static const char *const opts[] = {"stop", "restart", "collect",
144 "count", "step", "setpause", "setstepmul",
145 "setmajorinc", "isrunning", "generational", "incremental", NULL};
146 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
147 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
148 LUA_GCSETMAJORINC, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
149 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
150 int ex = luaL_optint(L, 2, 0);
151 int res = lua_gc(L, o, ex);
152 switch (o) {
153 case LUA_GCCOUNT: {
154 int b = lua_gc(L, LUA_GCCOUNTB, 0);
155 lua_pushnumber(L, res + ((lua_Number)b/1024));
156 lua_pushinteger(L, b);
157 return 2;
158 }
159 case LUA_GCSTEP: case LUA_GCISRUNNING: {
160 lua_pushboolean(L, res);
161 return 1;
162 }
163 default: {
164 lua_pushinteger(L, res);
165 return 1;
166 }
167 }
168}
169
170
171static int luaB_type (lua_State *L) {

Callers

nothing calls this directly

Calls 5

luaL_checkoptionFunction · 0.70
lua_gcFunction · 0.70
lua_pushnumberFunction · 0.70
lua_pushintegerFunction · 0.70
lua_pushbooleanFunction · 0.70

Tested by

no test coverage detected