[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Re: How to find out current stack size?
- From: Taj Khattra <taj.khattra@...>
- Date: Mon, 24 Nov 2003 21:20:17 -0800
On Mon, Nov 24, 2003 at 12:28:05PM +0100, firstname.lastname@example.org 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
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).