[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: The life cycle of userdata values?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 25 Jul 2016 16:03:44 -0300
> > 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