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
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
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
Hope this helps and I'm not telling you that Julia can do less than it
actually does (or you think it does)..