[Python-Dev] howto return malloc()ed memory from C -> Python (original) (raw)

Uwe Mayer merkosh at hadiko.de
Wed Mar 22 11:12:52 CET 2006


Hi,

I am wrapping libsndfile to Python, using SWIG and don't know howto return a malloc()ed memory area back to Python.

I've found CObjects, which would let me pass free() as cleanup function, but I'd rather return a buffer object (PyBuffer_FromReadWriteMemory) so that I could prevent copying of data, but I don't know how to prevent the memory leak then. Can I install some kind of cleanup hook?

Please also reply to me personally, as I am not on the python-dev list.

Thanks, Uwe

Conway's Law: In any organization there will always be one person who knows what is going on.

This person must be fired.

-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: not available Url : http://mail.python.org/pipermail/python-dev/attachments/20060322/0b7cd7b4/attachment.pgp



More information about the Python-Dev mailing list