I need to call a function in a C library from python, which would free() the parameter. So I tried create_string_buffer(), but it seems like that this buffer would be freed by Python later, and this would make the buffer be freed twice.
I read on the web that Python would refcount the buffers, and free them when there is no reference. So how can I create a buffer which python would not care about it afterwards? Thanks.
example:
I load the dll with: lib = cdll.LoadLibrary("libxxx.so")
and then call the function with: path = create_string_buffer(topdir)
and lib.load(path)
. However, the load function in the libxxx.so would free its argument. And later "path" would be freed by Python, so it is freed twice