[PyKDE] SIP: /Array/ and memory deallocation

Giovanni Bajo rasky at develer.com
Wed Mar 22 13:43:12 GMT 2006


I have an API like this:

class Foo
    Foo(char *filename);
    Foo(char *buffer, int size);

To make both construction forms work, I have wrapped the second constructor
as a staticmethod factory, using /Array/ and /ArraySize/ (this is because
overload resolution can't work, as both forms would get a Python string

The problem is the ownership of the buffer pointer. The C++ Foo API expects
the buffer to stay alive for the lifetime of the Foo instance. Is there an
immediate way to implement this? I was thining of storing the buffer as
Pything string object in a "secret" member of the Foo wrapped instance. Does
that sound like a good solution?

Giovanni Bajo

More information about the PyQt mailing list