|
On 30-Aug-05, at 5:24 PM, Brent Arias wrote:
If I'm recursing deeply (pushing a couple parameters on the stack eachtime), and I'm checking lua_gettop(..) each time through, I presume it will be larger each time? That is, lua_gettop reveals the total stack size, notjust the size of the current recursive frame?
lua_gettop() at entry to a function tells you (precisely) the number of arguments supplied. Stack indices are within the current stackframe; all other frames are invisible.
There is no API to tell you how big the total stack is. You shouldn't care, really.
Recursing through a lua_CFunction uses up C stack frames as well as Lua stack frames. The MAXCCALLS setting is deliberately kept low in order to minimize the danger of overflowing the C stack, as I understand it, since there is no reliable way to test for this condition (whereas Lua can and does test for an out-of-memory condition when attempting to expand the Lua stack.)
Read the reference manual's short but precise section on the Lua API for more details :)
R.