When to free memory for C wrapper?

Java and Swing codecraig at gmail.com
Thu Oct 13 09:40:09 EDT 2005


I have been posting lately about writing a C wrapper so Python can
access my C functions.

In my wrapper function I have something like...

static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
    PyObject *data;
    char *result;
    long *d;

    PyArg_ParseTuple(args, "O:wrap_doStuff", &data);

    d = get_long_array(data);

    result = doStuff(d);

    return PyString_FromString(result);
}

Now, do I need to use PyMem_Free to free up the "PyObject *data"?

Thanks.




More information about the Python-list mailing list