Yes, you're right. I did the cast because I get a compilation error without it.
The following results in: invalid conversion from ‘void*’ to ‘test*’
Code:
test *to = destination;
I used malloc() because I though there were something wrong with my C++ code.
Originally Clone() was not function, it was a method that uses new operator to dynamically allocate memory.
I also tried overloading new() and returning the start of the shared memory. It wasn't work either. It will be crazy to write a function that updates the pointer in every method that manipulates the object so I voted to a simply structure that imitates straightforward memory allocation but as you saw it wasn't that simple (at least for me).