C Extension memory troubles

Paul Simmonds psimmo60 at hotmail.com
Wed Jun 4 10:40:47 EDT 2003


Hi all,

I'm writing a wrapper for a C library at the moment, and one
of the things I need is a value that is meaningful to Python,
but it's actual value is in memory under a void pointer.
For convenience, I've hidden it in a PyCObject.

However, it appears that the memory used by the C variable is
reclaimed. For example...
>>>import voidptr
>>>voidptr.VoidPtr_AsObject(voidptr.VoidPtr_FromObject(1))
1
...works fine, but...
>>>a=voidptr.VoidPtr_FromObject(1)
>>>a
<PyCObject object at 0x8154320>
>>>voidptr.VoidPtr_AsObject(a)
135612696
...um.

Both values are returned using Py_BuildValue, which should
automatically INCREF them. Right? Or maybe it's something
else I've missed. Any thoughts?

TIA,
Paul

_________________________________________________________________
Sign-up for a FREE BT Broadband connection today! 
http://www.msn.co.uk/specials/btbroadband






More information about the Python-list mailing list