is Marshal::FreeHGlobal() possible?

G

Guest

Hi,

After converting String* to Char*, I need to call Marshal::FreeHGlobal().
Fine. But I need pass this Char* to an unmagaed C++ class and the managed C++
class is not possible to do Marshal::FreeHGlobal() any more. What should I
do? delete Char* in the unmanaged class?

Thanks
 
G

Guest

Calling delete[] on the char array may do the trick, but if it was created
using StringToHGlobal*, it may be possible that other objects may have been
created that could only be deleted w/ a call to FreeHGlobal. I think you
should be good though, worst case scenario is you would have to perform yet
another copy of the char array returned by StringToHGlobal* using strcpy or
something similar.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top