Hi,
I would to know if this code is safe or if I need to pin_ptr my Object^* parameter before using it.
ref struct A { System::String ^s; }; void test2(A ^* po) { (*po)->s = "test2"; // is it safe ? } void test(A ^* po) { pin_ptr<A^> pin_po = po; // this is obviously safe (*pin_po)->s = "test"; } int main(array<System::String ^> ^args) { A ^a = gcnew A(); test(&a); test2(&a); return 0; }
I don't know exactly how the garbage collector reads local variables so I am not sure if it understands that Object^* can be readen during collection.
Thank you in advance,
R.H.