is Marshal::FreeHGlobal() possible?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
Back
Top