lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Nov 24, 2003 at 12:28:05PM +0100, gradha29oct@ya.com  wrote:
> With lua_checkstack() I could always pass 0 in my first call,
> retrieve the stack elements with lua_gettop() and assume that
> is the whole stack size. I would then need to store that in
> some wrapper structure with a lua_state and this value I
> guessed. I'd prefer if there was an API call to avoid me
> duplicating the stack size in some extra variable.

sorry, i think i misunderstood your original question.  if you want to
check for accidental stack overflow, enable the api_check() macro in
lapi.c (see http://lua-users.org/lists/lua-l/2003-11/msg00150.html ).
then if you try to exceed the stack capacity, you will get an assertion
violation.

btw, lua_checkstack() doesn't quite work as you described it above.
lua_checkstack(L, 0) is effectively a no-op since lua_checkstack()
never shrinks the stack (see the reference manual).

-taj