lua-users home
lua-l archive

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


Em sex., 26 de fev. de 2021 às 22:25, Sean Conner <sean@conman.org> escreveu:
        * You cleanup the stack, thus removing the stack entry with the
          userdata.
In your opinion, this code is correct?

if (lua_getmetatable(L, 2)) {
    lua_getfield(L, -1, "namefield");
    if (lua_isuserdata(L, -1)) {
         MyCtype func = (MyCtype) lua_touserdata(L, -1);
          int n = 1;

          if (func != NULL) {
              void * child = lua_touserdata(L, 2);

              control = (*func)(child);
              ++n; /* pop child */
          }
          lua_pop(L, n); /* pop child and MyCType */
     }
}
 
regards,
Ranier Vilela