I want to get some string from a C/C++ library with ctypes into python. My code looks like this:
Code in lib:
const char* get(struct something *x)
{
a cheap hack around freeing the memory is to allocate it statically in C and never free it. only works if you know the maximum amount you need, of course, and if you know that you're done with before a second call to your routine.
static char _externalStringBuffer[MAX_BUFFER_SIZE];
char *get() {
// put characters in _externalStringBuffer
return _externalStringBuffer;
}