Hi,
I am working in mixed mode (managed C++ and C++ in one assembly). I am in a situation something like this.
ManagedStructure ^ managedStructure = gcnew ManagedStructure();
//here i set different properties of managedStructure
then I call "Method" given below and pass it "& managedStructure"
Method(void *ptrToStruct)
{
ManagedStructure ^ managedStructure2 = gcnew ManagedStructure();
memcpy(&managedStructure2 , ptrToStruct, sizeof(managedStructure2 ));
}
I have following question about this scenario.
1) Is it safe to use memcpy like this? and if not what is its alternate to achieve same functionality? ( I can't change "Method" definition)
2) I am not freeing any memory as both the structures are managed. Is it fine?