| 95 | |
| 96 | |
| 97 | LUA_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 | |
| 118 | LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { |
no test coverage detected