C Wrapper Function, crashing Python?

Bernhard Herzog bh at intevation.de
Wed Oct 12 18:05:22 CEST 2005

"Java and Swing" <codecraig at gmail.com> writes:

> static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
>       char *aString = 0;
>   	char *bString = 0;
>   	int ok = PyArg_ParseTuple(args, "sss", &in, &aString, &bString);
> 	free(aString);
>  	free(bString);

aString and bString are pointers to memory managed by the strings in
your args tuple.  You must not free them!  The memory is automatically
managed by Python.


Intevation GmbH                                 http://intevation.de/
Skencil                                           http://skencil.org/
Thuban                                  http://thuban.intevation.org/

More information about the Python-list mailing list