[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: light userdata (Was: Fastest way to transfer data from C to Lua ?)
- From: David Demelier <demelier.david@...>
- Date: Thu, 20 Jun 2013 22:11:06 +0200
2013/6/20 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
>> > I think nobody should give lightuserdata to a script just like a variable.
>>
>> I'm not sure what you mean exactly here, but giving userdata, light or
>> not, to a Lua script is totally harmless because userdata has no instrinsic
>> operations, except for equality test. The real issue is sending userdata
>> to the host: C code must ensure the validity of the corresponding pointer.
>
> I guess what he means is that it is not trivial to ensure the validity
> of a light userdata. So, more often than not, when a lightuserdata
> goes to a script, it ends up being used by its corresponding C library
> without a proper validation.
>
> -- Roberto
>
Yes, just like Roberto said, I'm more talking about an "ownership" of
pointer. If a C function pass a lightuserdata to Lua and this script
store it, the pointer may be invalidated by the C host at any time.
That's why I advise to use real userdata when we don't know when the
data will be deleted.
Sorry for not being concise, I'm not native english speaker..
Regards,
--
Demelier David
- References:
- Re: Fastest way to transfer data from C to Lua ?, David Heiko Kolf
- RE: Fastest way to transfer data from C to Lua ?, Geoff Smith
- Re: Fastest way to transfer data from C to Lua ?, Sean Conner
- Re: Fastest way to transfer data from C to Lua ?, Jorge
- RE: Fastest way to transfer data from C to Lua ?, Geoff Smith
- Re: Fastest way to transfer data from C to Lua ?, Tim Hill
- light userdata (Was: Fastest way to transfer data from C to Lua ?), David Heiko Kolf
- Re: light userdata (Was: Fastest way to transfer data from C to Lua ?), Tim Hill
- Re: light userdata (Was: Fastest way to transfer data from C to Lua ?), David Demelier
- Re: light userdata (Was: Fastest way to transfer data from C to Lua ?), Luiz Henrique de Figueiredo
- Re: light userdata (Was: Fastest way to transfer data from C to Lua ?), Roberto Ierusalimschy