MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_checkstack

Function lua_checkstack

depends/lua/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 15

init_run_scriptFunction · 0.85
init_enable_scriptFunction · 0.85
is_builtinMethod · 0.85
get_commandsFunction · 0.85
help_helperMethod · 0.85
tags_helperFunction · 0.85
ls_helperFunction · 0.85
push_simple_errorFunction · 0.85
do_finish_pcallFunction · 0.85
CallLuaModuleFunctionMethod · 0.85
resume_helperFunction · 0.85
dfhack_coauxwrapFunction · 0.85

Calls 1

luaD_rawrunprotectedFunction · 0.85

Tested by

no test coverage detected