Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED

  • From: Patrick Masotta <masottaus@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 21 Jun 2012 06:33:29 -0700 (PDT)

I agree that's why I'm setting the string size considering the max length the 
variable can hold...
as far as I know I can strcpy/strcat from the C side as far as I do not pass 
the size defined on the LUA side i.e

local  var_01 = ffi.new("char[50]", "default value for var_01" );

from C I see var_01 points to a 50 byte string then
strcpy(var_01,...
strcat(var_01,...
woul be fine while strlen(var_01)<50   right?


--- On Thu, 6/21/12, Robert G. Jakabosky <bobby@xxxxxxxxxxxxxxx> wrote:

> From: Robert G. Jakabosky <bobby@xxxxxxxxxxxxxxx>
> Subject: Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails 
> PROBABLY SOLVED
> To: luajit@xxxxxxxxxxxxx
> Date: Thursday, June 21, 2012, 6:25 AM
> On Thursday 21, Patrick Masotta
> wrote:
> > I see, good info;
> > I need a C string because is going to be altered from
> the C side then
> > casting a LUA string is not an option. in the
> particular case of "message"
> > strings (only for display on the C side)the casting
> option you mention
> > would work but I'm also trying to make life easier to
> the one that has to
> > define these strings providing an homogeneous sytem
> 
> Keep in mind that the C side can't grow the char array (no
> calling realloc) or 
> append to it (strcat), since it will be restricted to the
> length of the 
> initial Lua string.
> 
> -- 
> Robert G. Jakabosky
> 
> 

Other related posts: