Dear Fengyang and Yichao,

I think my code is fully operational at this point.  Thanks for the help! 
 Cholmod/sqpr have their own memory management routines, so I used 
cholmod_l_free to free E.  And the reason that my wrapper did not find the 
permutation inside of return variable E is because E was declared as 
Ptr{Clong}, which is the same as Ptr{Int32}, but E is actually an array of 
Int64 on my platform.  So each index inside of E was cut in two by the 
previous version of the wrapper, which explains why E seemed to have so 
many 0's.

-- Steve

On Friday, August 5, 2016 at 12:57:27 AM UTC-4, Fengyang Wang wrote:
>
> Generally, pointers returned from ccalls should be freed with the free 
> function from the same library. From the documentation of Libc.free:
>
> Call free from the C standard library. Only use this on memory obtained 
>> from
>> malloc, not on pointers retrieved from other C libraries. Ptr objects
>> obtained from C libraries should be freed by the free functions defined in
>> that library, to avoid assertion failures if multiple libc libraries exist
>> on the system.
>>
>
> So the correct ccall should be: ccall((:free, :libspqr), Void, 
> (Ptr{Void},), ptr). This is presuming, of course, that the pointer was 
> allocated using malloc; this is almost certainly the case.
>

Reply via email to