func = ctypes.cdll.TestDLL.func
func.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
func.restype = ctypes.c_void_p
freeMem = ctypes.cdll.TestDLL.freeMem
freeMem.argtypes = [ctypes.c_void_p]
freeMem.restype = None
s = func('abcdef', 'ghijkl')
s = ctypes.cast(s, ctypes.c_char_p)
print(s.value)
freeMem(s)
How to pass pointer back in ctypes?