Given a ctypes structure and instances:
class MyStruct(Structure):
_fields_ = [
('length', c_int),
('data', c_void_p)
]
one = MyStruct()
two = MyStruct()
How can I make a copy of the content that one.data
points to and make two.data
point to the new memory copy. I don't just want to copy the pointers themselves.
Assuming one.data != two.data
, it seems like the answer should be quite straight forward using memmove
, such as:
memmove(two.data, one.data, one.length)
But I can't quite get it right.