lua-users home
lua-l archive

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

Maybe this is obvious but...

I started implementing Perl-style pack/unpack functions using Lua strings for binary data but
ran into a snag.  Using strings is fine if you're just looking to write data out to a file.
However if you want to pass the strings to C to be used directly then there are alignment

Because of the way string data is represented in Lua, it will not have the alignment in use by
malloc but instead malloc's alignment plus some constant offset depending on the position of the
"str" field in the TString structure of lobject.h.  (Based on first guess.)