On Tue, Aug 14, 2012 at 3:29 PM, Digital <forumme5487@live.com> wrote:
From within lua
//------------------------------
somevar = require "modulename";
data = "binary data";
somevar.testfunc(data);
//-------------------------------
It works for anything normal like string "abc123" but as soon as I add
binary data it stops functioning.
Why are you using string functions in C? strlen is going to break on
embedded nulls, for example. If you're storing, say, numbers as 32-bit
big-endian values, you're going to hit an embedded null very early on
and your C code will fail.
Your Lua code is probably fine. Just use the Lua C API to find the
length of the binary data (Lua uses length-tagged strings, not
null-terminated) and deal with it that way.
/s/ Adam