| 173 | |
| 174 | |
| 175 | void luaD_growstack (lua_State *L, int n) { |
| 176 | int size = L->stacksize; |
| 177 | if (size > LUAI_MAXSTACK) /* error after extra size? */ |
| 178 | luaD_throw(L, LUA_ERRERR); |
| 179 | else { |
| 180 | int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK; |
| 181 | int newsize = 2 * size; |
| 182 | if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; |
| 183 | if (newsize < needed) newsize = needed; |
| 184 | if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ |
| 185 | luaD_reallocstack(L, ERRORSTACKSIZE); |
| 186 | luaG_runerror(L, "stack overflow"); |
| 187 | } |
| 188 | else |
| 189 | luaD_reallocstack(L, newsize); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | |
| 194 | static int stackinuse (lua_State *L) { |
no test coverage detected