Tiago Pereira wrote:
> Robert Bradshaw wrote:
> 
>> You have to manually allocate b. Also, it's not guaranteed that the  
>> array is contiguous--you may need to look at the stride information.
> 
> I understand the part about contiguous, and I've seen examples on how to
> deal with it. So if I manually allocate, I guess I'll have to free it
> later too. But forgive me my ignorance, how do I do that in cython? In C
> I would do:
> 
> b = (float **) malloc(N * sizeof(float*));
> for(i = 0; i < N; i++)
>     b[i] = (float *) malloc(N * sizeof(float));

No, only the first line. You assign b[i] to point to memory in your 
contiguous array; which is already allocated.

Anyway, you do the same in Cython:

from stdlib cimport free, malloc

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to