Hi,

Does ctypes, when using restype, frees allocated memory?

For example, will the memory allocated by "strdup" be freed after the "del" 
statement? If not, how can I free it?

---
import ctypes

libc = ctypes.cdll.LoadLibrary('libc.so.6')
strdup = libc.strdup
strdup.argtypes = [ctypes.c_char_p]
strdup.restype = ctypes.c_char_p

out = strdup(b'hello').decode('utf-8')
print(out)  # hello
del out
---

Thanks,
Miki
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to