** Compute how much of the stack is being used, by computing the ** maximum top of all call frames in the stack and the current top. */
| 274 | ** maximum top of all call frames in the stack and the current top. |
| 275 | */ |
| 276 | static int stackinuse (lua_State *L) { |
| 277 | CallInfo *ci; |
| 278 | int res; |
| 279 | StkId lim = L->top.p; |
| 280 | for (ci = L->ci; ci != NULL; ci = ci->previous) { |
| 281 | if (lim < ci->top.p) lim = ci->top.p; |
| 282 | } |
| 283 | lua_assert(lim <= L->stack_last.p + EXTRA_STACK); |
| 284 | res = cast_int(lim - L->stack.p) + 1; /* part of stack in use */ |
| 285 | if (res < LUA_MINSTACK) |
| 286 | res = LUA_MINSTACK; /* ensure a minimum size */ |
| 287 | return res; |
| 288 | } |
| 289 | |
| 290 | |
| 291 | /* |