lua-users home
lua-l archive

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


On Thu, Sep 11, 2008 at 3:09 AM, Aladdin Lampé <genio570@hotmail.fr> wrote:
>
>
> Hi!
> 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!
> Aladdin

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.

Cheers,

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant