[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: light userdata (Was: Fastest way to transfer data from C to Lua ?)
- From: Tim Hill <drtimhill@...>
- Date: Sun, 9 Jun 2013 13:29:07 -0700
Not true, there is nothing to prevent you taking a copy of the light user data from the table. The point is that neither Lua nor C can know when the item is freed at the language level .. your application might have business rules that controls the lifecycle, which is fine (just like you have to manage pointers by hand in C).
On Jun 9, 2013, at 8:26 AM, Kevin Martin <firstname.lastname@example.org> wrote:
> On 9 Jun 2013, at 12:05, Tim Hill wrote:
>> so it is of limited use unless the pointer is to static memory or heap memory that will not be released until after the Lua state is closed. I'm with you.
> This isn't true if the light userdata are stored in a table which has a gc metamethod to call the appropriate free function.
> I hardly ever use full userdata as an object, but instead use a table and put light userdata in it. I find it much more flexible than full userdata.