The example works for me, i.e., does not crash.
It does leak memory: the entries of adj, the C++ object m, and the returned
clverts. You need to use free(), normal delete, and array delete to
deallocate them respectively. The array delete operator is not available in
Cython, but you can probabl
Volker,
On Friday, 21 March 2014 19:48:52 UTC+1, Volker Braun wrote:
>
> You must not mix new/delete and malloc/free, that is, the deallocation
> must match the allocation. It sounds really wonky for a C++ library to
> require a malloc'ed buffer as input and returning something array new'ed,
You must not mix new/delete and malloc/free, that is, the deallocation must
match the allocation. It sounds really wonky for a C++ library to require a
malloc'ed buffer as input and returning something array new'ed, though. Are
you sure that this is what your problem is?
The "array new" operato
Volker,
The library in question does need me to pass a C array. I am currently
overcoming the problem by using malloc but fter the library call I get a
corrupt pointer back, that I cannot free. Hence I am trying to see how
would it work with new/delete.
Best,
Jernej
On Friday, 21 March 2014
You aren't even trying to construct a C++ objects. Unless your C++ library
expects C arrays as inputs, I would recommend that you forget about them.
Use STL vectors as containers. See src/sage/tests/stl_vector.pyx for an
example.
On Friday, March 21, 2014 7:41:08 AM UTC-4, Jernej Azarija w