Note that sizeof is a builtin keyword though (so no stdlib there).

Dag Sverre Seljebotn
-----Original Message-----
From: Brent Pedersen <[email protected]>
Date: Saturday, Aug 8, 2009 5:22 am
Subject: Re: [Cython] malloc(), free() via include "stdlib.pxi"
To: [email protected]: [email protected]

On Fri, Aug 7, 2009 at 7:46 PM, Christian<[email protected]> wrote:
> Hello,
>
>> I try to implement a dynamic array in cython with malloc and free.
> My current problem is, that these functions are not builtins. After a
> little research in the documentation I have found the following wiki
> article:
>
>> http://wiki.cython.org/DynamicMemoryAllocation
>
>> My problem seems to be solved by including "stdlib.pxi"
> But when I add this line at the top of my pyx file and try to compile
> it. I get the following error:
>
>> 'stdlib.pxi' not found
>
>> I tried to add the lib to my setup.py as an additional source file, but
> nothing changes. I get the same error.
>
>> How do I include the stdlib file correctly?
>
>>
>
>> Thank you in advance
>
>> Christian
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>
>
>hi, stdlib is included with cython. so i think you can just do something like:
>
>cimport stdlib
>cdef int* a = <int *>stdlib.malloc(N * stdlib.sizeof(int))
>a[2] = 1
>stdlib.free(a)
>_______________________________________________
>Cython-dev mailing list
>[email protected]
>http://codespeak.net/mailman/listinfo/cython-dev
>

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

Reply via email to