lua-users home
lua-l archive

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


You mean don't have to call lua_pop?
I have a bug reading an invalid pointer, in an adjacent library, which I'm not sure is caused by Lua gc.

regards,
Ranier Vilela

Em qua, 24 de fev de 2021 10:36 PM, Tim McCracken <Tim.McCracken@utelety.com> escreveu:
Why do you want to “clean” the stack? You may be making things harder than they are. Lua manages the “stack” for you.



Sent from my iPhone

On Feb 24, 2021, at 7:26 PM, Ranier Vilela <ranier.vf@gmail.com> wrote:


Hi Hackers,
How should the stack look after the calls below?

    lua_pushinteger(L, p1);
    lua_pushinteger(L, p2);
    lua_pushinteger(L, p3);
    lua_pushnumber(L, p4);
    lua_call(L, 4, 1);
    if (lua_isuserdata(L, -1)) {
        value = lua_tonumber(L, -1);
        lua_pop(L, 1);
    }
    lua_pop(L, lua_gettop(L));

What is the correct way to clean the stack?

regards,
Ranier Vilela