lua-users home
lua-l archive

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


> > p = lua_newuserdate(L, sizeof int)
> > *p = 42
> > 
> > /* Do a Lua API call that might error (longjmp) out */
> 
> This has the risk of the memory being invalidated by the
> garbage collector.

No, if the userdata is properly anchored (e.g, in the stack). Just
leave the the userdata in the stack (where lua_newuserdate put it)
and everything should work fine.

-- Roberto