I guessed the following code should work, but it does not. Could someone explain to me how to use this kind of pointer?Of course, this is only a sample code. What I need to solve is to use a pointer that comes from an external library (it has its own allocator 'library_allocete_memory' which is internally using malloc). I need to copy data into that memory from python code.
import ctypeslibc = ctypes.cdll.msvcrtdata = b'test data'size = len(data)ptr = libc.malloc(size)ptr = ctypes.cast(ptr, ctypes.c_char_p)# ptr = ctypes.create_string_buffer(size) # this is working, but I cannot allocate memory this way in my casectypes.memmove(ptr, data, size) # access violation is thrown here