MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / lua_checkstack

Function lua_checkstack

3rd/lua-5.4.3/src/lapi.c:99–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 5

luaL_checkstackFunction · 0.85
pmainFunction · 0.85
auxresumeFunction · 0.85
tunpackFunction · 0.85
checkstackFunction · 0.85

Calls 1

luaD_growstackFunction · 0.85

Tested by

no test coverage detected