how to free PyArg_Parse'd args?

Jason Orendorff jason at jorendorff.com
Wed Dec 19 12:31:27 EST 2001


Robert Nikander wrote:
> If I create a C extension class with a member char * name, and
> I get the name initially from a PyArg_ParseTuple(args, 's'...), 
> Who should I call to free it when the objects tp_dealloc slot is called?
> I am trying PyMem_Del/Free( obj->name ) but am getting a seg fault.

Don't free it.  You're given a pointer to the actual char buffer
within the provided string object.  It's like a borrowed reference.

-- 
Jason Orendorff    http://www.jorendorff.com/





More information about the Python-list mailing list