lua-users home
lua-l archive

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


2014-03-03 11:27 GMT+02:00  <dehmel.r@atg-lm.com>:
> Is this lua_settop(L, 0) or any other remove, ... not needed?
>
> static int Lcm_smw16(lua_State *L)
> {
>   Lcm* ud = (Lcm*)luaL_checkudata(L, 1, "Lcm");
>   int a = luaL_checkint(L, 2);
>   int d = luaL_checkint(L, 3);
>   int blind = luaL_optint(L, 4, 0);
>   lua_settop(L, 0); // <=== no need for this stack adjustment ?
>   lua_pushnumber(L, ud->smw16(a, d, blind));
>   return 1;
> }

Correct. No need.

Do a `grep settop` on Lua source that uses the API, e.g. ltablib.c,
to see how seldom it is needed.