[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: C extension and stack cleanup on error
- From: "Kacper Wysocki" <kacperw@...>
- Date: Tue, 10 Jul 2007 12:12:55 +0200
On 7/10/07, David Welch <email@example.com> wrote:
I am trying to write a C extension to lua and I am wondering what the
rules are when it comes to stack cleanup.
So this function is effectively type checking a tables field and
returning its value. If the field doesn't exist then an error
is raised and a nil value is left on the stack. If the field is there
but checkudata fails, once again a value is left on the stack.
What actually happens to the value left on the stack? Can I basically
just forget about it?
error() (and luaL_check*() calls error()) unwinds the stack for you so
you don't have to worry about it. It's when there is no error() that
you should pay attention to your stack.