MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / lua_checkstack

Function lua_checkstack

third-party/lua-5.3.5/src/lapi.c:97–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96
97LUA_API int lua_checkstack (lua_State *L, int n) {
98 int res;
99 CallInfo *ci = L->ci;
100 lua_lock(L);
101 api_check(L, n >= 0, "negative 'n'");
102 if (L->stack_last - L->top > n) /* stack large enough? */
103 res = 1; /* yes; check is OK */
104 else { /* no; need to grow stack */
105 int inuse = cast_int(L->top - L->stack) + EXTRA_STACK;
106 if (inuse > LUAI_MAXSTACK - n) /* can grow without overflow? */
107 res = 0; /* no */
108 else /* try to grow stack */
109 res = (luaD_rawrunprotected(L, &growstack, &n) == LUA_OK);
110 }
111 if (res && ci->top < L->top + n)
112 ci->top = L->top + n; /* adjust frame top */
113 lua_unlock(L);
114 return res;
115}
116
117
118LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {

Callers 5

luaL_checkstackFunction · 0.70
pmainFunction · 0.70
auxresumeFunction · 0.70
unpackFunction · 0.70
checkstackFunction · 0.70

Calls 1

luaD_rawrunprotectedFunction · 0.70

Tested by

no test coverage detected