I find it likely that this supports my case (there could be other reasons.. 
but Java's FFI is built on JNI, and ultimately on ccall).

"Multidimensional arrays, either as arguments or return values are not 
supported. Since Java uses Array-of-Arrays, unlike Julia's true 
multidimensional arrays, supporting them is non-trivial, though certainly 

Your case is array (one allocation) of strings (many allocation), just as 
how Java allocates "2D" arrays (only really supporting 1D). Unlike 2D (or 
3D etc.) of arrays, allocated in Julia and C/C++ (and some other languages, 
Fortran, Haskell(?)) as one allocation, e.g. true multidimensional arrays. 
Julia does them however better than C for other reasons.

On Thursday, October 13, 2016 at 12:39:21 PM UTC, Páll Haraldsson wrote:
> On Wednesday, October 12, 2016 at 4:19:17 PM UTC, Michael Eastwood wrote:
>> So what is the best way to get an array of strings from C back into 
>> Julia? I want Julia to take ownership of the memory. Do I need to query the 
>> length of each string ahead of time?
> I'm kind of guessing here, but I know Julia can take over A memory 
> allocation by C, e.g. if you get back a pointer to a [C] string.
> I doubt you can take over an array of pointers [to heap allocations] (or 
> just A pointer to a pointer). Julia would have to delete that array (ok), 
> but [first] go through it and delete what it points to (and recursively if 
> that applies).
> It would be cool, if Julia can do that, I just very much doubt it. I guess 
> you'll have to let C deallocate, and use a callback, or provide all the 
> strings.
> About the length of the strings however, Julia has a Cstring type that 
> assumes 0 (NULL) ending, and you do not have to worry about that (Julia 
> takes care of "length" issues then if needed). [You could also take over 
> other types of string], free doesn't really care about the length of thre 
> strings, allocations can be somewhat bigger, it takes care of the padding 
> to.
> Hope this helps and I'm not telling you that Julia can do less than it 
> actually does (or you think it does)..

Reply via email to