Re: [julia-users] Wrapping an array from C

2016-08-17 Thread Kiran Pamnany
On Wednesday, August 17, 2016 at 12:49:58 AM UTC-7, Bart Janssens wrote: > > It looks like ptr is actually an array of pointers? If so, you could > access the first element using: > unsafe_load(convert(Ptr{atyp}, p[1])) > > ptr is a pointer to the beginning of an array of structs. Steve has expla

Re: [julia-users] Wrapping an array from C

2016-08-17 Thread Bart Janssens
On Tue, Aug 16, 2016 at 10:29 PM Kiran Pamnany > 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 c

[julia-users] Wrapping an array from C

2016-08-16 Thread Kiran Pamnany
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