com interop - How can I delete a SAFEARRAY returned from a .NET function in native code? -


I am hosting a .NET library in my C ++ program using the following methods, although the complete list Do not have:

  CorBindToRuntimeEx () GetDefaultDomain () CreateInstance () GetIDsOfNames ()   

and finally call on invoke () Please.

This works well, but whenever a .NET function returns an array, such as:

  public int [] getArray () {int [ ] I = {0, 1, 2, 3}; Return i; }   

In this case, the function is a VARIANT type VT_SAFEARRAY | VT_I4 . I have tried to delete delete and [] on both the descriptor and PVDIT member, and it always fails. I have tried SafeArrayDestroy () descriptor, which succeeds but corrupts the heap, I SafeArrayDestroyData () on variant.parray-> gtc: pvData < / Code>, but works properly, but SafeArrayDestroyDescriptor () corrupts the pile again, I'm still leaking the array descriptor.

So, how can I choose SAFEARRAY descriptor and plug this memory leak?

impossible to guess without seeing the code

You should use the Variation Clar ().

Comments