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

Function lua_setcstacklimit

extlibs/lua/src/lstate.c:99–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98
99LUA_API int lua_setcstacklimit (lua_State *L, unsigned int limit) {
100 global_State *g = G(L);
101 int ccalls;
102 luaE_freeCI(L); /* release unused CIs */
103 ccalls = getCcalls(L);
104 if (limit >= 40000)
105 return 0; /* out of bounds */
106 limit += CSTACKERR;
107 if (L != g-> mainthread)
108 return 0; /* only main thread can change the C stack */
109 else if (ccalls <= CSTACKERR)
110 return 0; /* handling overflow */
111 else {
112 int diff = limit - g->Cstacklimit;
113 if (ccalls + diff <= CSTACKERR)
114 return 0; /* new limit would cause an overflow */
115 g->Cstacklimit = limit; /* set new limit */
116 L->nCcalls += diff; /* correct 'nCcalls' */
117 return limit - diff - CSTACKERR; /* success; return previous limit */
118 }
119}
120
121
122/*

Callers 1

db_setcstacklimitFunction · 0.85

Calls 1

luaE_freeCIFunction · 0.85

Tested by

no test coverage detected