help on python SWIG C++ extension
Tim Roberts
timr at probo.com
Wed Sep 17 02:16:25 EDT 2008
RLC <rogeruclan at gmail.com> wrote:
>
>I am new to python SWIG. Recently I wrote a small program trying to
>import collada files(using colladadom) into python so I could use
>python cgkit to render them. However, during the progressing, I got
>some problems. Every time I quit from Python, I get a segmentation
>fault, although the main program runs well. I suspect it is because I
>wrapped std::vector objects in C struct and I did not release the
>memory properly.
That won't cause a segmentation fault. However, I notice that you are
using "malloc" and "free" to allocate and free your objects. "stl" will
use "new" and "delete", and it's not always healthy to mix them. If I were
you, I'd replace this:
> Vertex *v;
> v = (Vertex *)malloc(sizeof(Vertex));
with this, which is less typing:
Vertex * x = new Vertex;
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list