lua-users home
lua-l archive

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

I agree... strings are an excellent way of getting arbitary data in
and out of Lua. All you probably need to do is pass the address and
length to lua_pushlstring. Lua makes its own copy, so you don't need
to worry about what Lua might do with it.


On 21 February 2010 18:10, steve donovan <> wrote:
> On Sat, Feb 20, 2010 at 11:58 PM, Peter Cawley <> wrote:
>> functions, etc. To get the contents of a userdata, you need to use the
>> C functions designed specifically for that userdata, which in turn
>> employ the base C API function lua_touserdata to get memory access to
>> the userdata.
> An interesting possibility is a small C extension which can work with
> arbitrary userdata as memory buffers, rather like how Alien works with
> buffers.  One could define a userdata-to-string converter, bearing in
> mind that Lua strings can contain embedded nuls and then use one of
> the struct, pack, etc libraries to decode that string.