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:
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Peter Cawley
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Robert G. Jakabosky
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Michal Kottman
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Paulo Matias
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Robert G. Jakabosky
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Robert G. Jakabosky
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Robert G. Jakabosky
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Claire Lewis
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED - Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Claire Lewis
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Javier Guerra Giraldez
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Coda Highland
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Adam Strzelecki
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Coda Highland
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Geoff Leyland
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Geoff Leyland
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Dimiter 'malkia' Stanev
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Claire Lewis
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Sean Conner
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- dcharno
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Craig Barnes
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Adam Strzelecki
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » RE: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- William Adams