Re: ctypes: delay conversion from c_char_p to string

2010-04-24 Thread Thomas Heller
Brendan Miller schrieb: I have a function exposed through ctypes that returns a c_char_p. Since I need to deallocate that c_char_p, it's inconvenient that ctypes copies the c_char_p into a string instead of giving me the raw pointer. I believe this will cause a memory leak, unless ctypes is

Re: ctypes: delay conversion from c_char_p to string

2010-04-22 Thread Zvezdan Petkovic
On Apr 21, 2010, at 6:29 PM, Brendan Miller wrote: Here's the method I was using. Note that tmp_char_ptr is of type c_void_p. This should avoid the memory leak, assuming I am interpreting the semantics of the cast correctly. Is there a cleaner way to do this with ctypes? def

Re: ctypes: delay conversion from c_char_p to string

2010-04-22 Thread Zvezdan Petkovic
On Apr 22, 2010, at 10:49 AM, Zvezdan Petkovic wrote: libc.strdup.argtype = [ctypes.c_char_p] Correcting my typo. This should be in plural: libc.strdup.argtypes = [ctypes.c_char_p] -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes: delay conversion from c_char_p to string

2010-04-22 Thread Brendan Miller
On Thu, Apr 22, 2010 at 7:49 AM, Zvezdan Petkovic zvez...@zope.com wrote: On Apr 21, 2010, at 6:29 PM, Brendan Miller wrote: Here's the method I was using. Note that tmp_char_ptr is of type c_void_p. This should avoid the memory leak, assuming I am interpreting the semantics of the cast

ctypes: delay conversion from c_char_p to string

2010-04-21 Thread Brendan Miller
I have a function exposed through ctypes that returns a c_char_p. Since I need to deallocate that c_char_p, it's inconvenient that ctypes copies the c_char_p into a string instead of giving me the raw pointer. I believe this will cause a memory leak, unless ctypes is smart enough to free the

Re: ctypes: delay conversion from c_char_p to string

2010-04-21 Thread Brendan Miller
Here's the method I was using. Note that tmp_char_ptr is of type c_void_p. This should avoid the memory leak, assuming I am interpreting the semantics of the cast correctly. Is there a cleaner way to do this with ctypes? def get_prop_string(self, prop_name): # Have to work with