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

Function luaD_growstack

extlibs/lua/src/ldo.c:209–232  ·  view source on GitHub ↗

** Try to grow the stack by at least 'n' elements. when 'raiseerror' ** is true, raises any error; otherwise, return 0 in case of errors. */

Source from the content-addressed store, hash-verified

207** is true, raises any error; otherwise, return 0 in case of errors.
208*/
209int luaD_growstack (lua_State *L, int n, int raiseerror) {
210 int size = L->stacksize;
211 int newsize = 2 * size; /* tentative new size */
212 if (unlikely(size > LUAI_MAXSTACK)) { /* need more space after extra size? */
213 if (raiseerror)
214 luaD_throw(L, LUA_ERRERR); /* error inside message handler */
215 else return 0;
216 }
217 else {
218 int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK;
219 if (newsize > LUAI_MAXSTACK) /* cannot cross the limit */
220 newsize = LUAI_MAXSTACK;
221 if (newsize < needed) /* but must respect what was asked for */
222 newsize = needed;
223 if (unlikely(newsize > LUAI_MAXSTACK)) { /* stack overflow? */
224 /* add extra size to be able to handle the error message */
225 luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror);
226 if (raiseerror)
227 luaG_runerror(L, "stack overflow");
228 else return 0;
229 }
230 } /* else no errors */
231 return luaD_reallocstack(L, newsize, raiseerror);
232}
233
234
235static int stackinuse (lua_State *L) {

Callers 1

lua_checkstackFunction · 0.85

Calls 3

luaD_throwFunction · 0.85
luaD_reallocstackFunction · 0.85
luaG_runerrorFunction · 0.85

Tested by

no test coverage detected