[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: binary data as string snag
- From: "John Belmonte" <jvb@...>
- Date: Tue, 6 Feb 2001 19:54:49 +0900
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.)