(I dind’t find an official Ruby FFI mailing-list so I try here)
I have a char array baked into a struct (not a pointer), and I have
problems describing it in a layout.
The only thing I’ve come up with is to have a dummy variable at the end.
class MyArray_t < FFI::Struct
layout :Value, :uint8,
:Dummy, :uint8, SIZE_OF_ARRAY+1 # TODO TODO
And I use it something like this:
arr = MyArray_t.new
c_function(arr.pointer) # calls a c function that fills the string
str_ptr = arr.pointer + arr.offset_of(:String)
I need the dummy otherwise there wont be enough bytes allocated and
c_function overwrites the heap.
Any and all help appreciated. (Note that it’s a legacy API,
redesigning the C-interface is not possible.)