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 07:49:17 -0700 (PDT)

I see, good example about the casting...
and yes I'm always passing the size betwen LUA and C.

thanks


> The reason for my question about passing the limit to the C
> side is that 
> seeing code that uses strcpy/strcat makes me nervous, since
> it is very easy to 
> overflow the buffer.
> 
> Ah, I wasn't thinking about the issue of passing Lua numbers
> to vararg 
> functions.  I had just thrown that example
> together.  The FFI docs say you 
> have to cast the Lua number to an int, since LuaJIT doesn't
> know that the 
> function wants an int instead of a double.
> 
> -- Example from the FFI docs:
> ffi.C.printf("integer value: %d\n", ffi.new("int", x))
> 
> 
> -- 
> Robert G. Jakabosky
> 
>

Other related posts: