[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_checkstack and luaL_checkstack
- From: "Patrick Donnelly" <batrick.donnelly@...>
- Date: Thu, 11 Sep 2008 03:15:20 -0600
On Thu, Sep 11, 2008 at 3:09 AM, Aladdin Lampé <firstname.lastname@example.org> wrote:
> In some C source interfacing with Lua I found lots of:
> lua_checkstack(L, nb);
> with no return value check. Is it of any use or can I either
> - remove them?
> - use luaL_checkstack(L, nb, "out of memory"); instead?
> What would you recommend? Is it really necessary to check the stack each time you push something to it or will the VM raise the "out of memory" error anyway?
> Thank you!
You should check the return value. Not doing so can lead to you
pushing items over the stack top causing a segmentation fault.
luaL_checkstack is the best option IME.
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."