I have a C function:
int foo(foo_t *handle, int idx, void **ptr);
foo() fills in ptr which points at (part of) an array of elements that was
previously allocated. I want to call this function from Julia.
For a bits type (i.e. Int64), the following works:
p = [C_NULL]
ccall((:foo, libfoo), Cint, (Ptr{Void}, Cint, Ptr{Ptr{Void}}), h, i, pointer
(p, 1))
return unsafe_wrap(Array, convert(Ptr{atyp}, p[1]), hi[idx]-lo[idx]+1)
atyp stores the type of the elements in the array that foo() returns.
If I use a composite type, Bar, instead of a bits type, then I get back an
array of Bar, but each element is #undef. The memory for the elements of
the array is present (sizeof(Bar) was used to allocate the space), but the
array isn't set up correctly. How can I do this?
Any help is much appreciated!
Thanks in advance,
K