2D arrays - casting and accessing

  • From: Cosmin Apreutesei <cosmin.apreutesei@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 14 Sep 2012 22:06:58 +0300

Hi,

I have a 2D array defined as "unsigned char[?][128]". I want to pass
it to png_read_image() from libpng that takes unsigned char**. Should
ffi.cast alone work? Does a 2D VLA have the same layout as in C, an
array of pointers to 1D arrays? I'm asking because ffi.cast('char**',
buf)[0] returns NULL, and I can't fill up the buffer either.

Any help appreciated.

Other related posts: