Hello everyone, 

I just got started with Julia, and I wanted to try to wrap a C/C++ library 
to Julia to check whether it would work out for my purposes.

I tried out many ways of passing arrays and other objects from C back to 
Julia.
So far it seems that it takes a lot of extra code if I want to return, for 
example, a simple double-array or an array of types (eg structs).

Then I thought that I could call the Julia API from the ccalled binary, to 
allocate an array and return it to julia,
then use unsafe_pointer_to_objref() and get a neat Julia object directly.

You can see a very simple example here 
https://gist.github.com/anonymous/8888647

This would simplify _significantly_ a lot of code from the C side, at least 
with what I am working right now.

Now, my question is: is it safe to call functions such as jl_alloc_array_1d() 
from the C binary?
would this be a problem in some situations?

I understand that it may mess memory up if those functions are called 
outside the main thread, but I would certainly not do that.

Thanks in advance,
Carlos

Reply via email to