| 248 | |
| 249 | |
| 250 | static int stackinuse (lua_State *L) { |
| 251 | CallInfo *ci; |
| 252 | int res; |
| 253 | StkId lim = L->top; |
| 254 | for (ci = L->ci; ci != NULL; ci = ci->previous) { |
| 255 | if (lim < ci->top) lim = ci->top; |
| 256 | } |
| 257 | lua_assert(lim <= L->stack_last); |
| 258 | res = cast_int(lim - L->stack) + 1; /* part of stack in use */ |
| 259 | if (res < LUA_MINSTACK) |
| 260 | res = LUA_MINSTACK; /* ensure a minimum size */ |
| 261 | return res; |
| 262 | } |
| 263 | |
| 264 | |
| 265 | /* |