Q: memory ownership in python extensions

Frank Stajano fstajano at uk.research.att.com
Wed Jun 28 12:05:36 EDT 2000


On Tue, 27 Jun 2000 17:34:25 GMT, fstajano at uk.research.att.com (Frank
Stajano) wrote:

>In the C code, I malloc some memory, perform some processing that
>writes a string in it, then turn this C string into a Python string
>via Py_BuildValue. The question is: Who is responsible for freeing
>that memory?

The answer comes from the NEXT version of the docs, quoted below
(thanks Fred) ;-)

When memory buffers are passed as parameters to supply data to build
objects, as for the \samp{s} and \samp{s#} formats, the required data
is copied.  Buffers provided by the caller are never referenced by the
objects created by \cfunction{Py_BuildValue()}.



More information about the Python-list mailing list