[Mono-list] Embedded Mono using DllImport(__Internal) and returning string

efontana eric at fontanas.net
Mon Mar 12 19:51:41 UTC 2012


I'm using Embedded Mono and P/Invoke DllImport.   If I have a method which
returns a string


  [DllImport("__Internal", EntryPoint = "CSharp_Test_ReturnString")]
    public extern static string CSharp_Test_ReturnString();

The corresponding "C" method should strdup the string right?

extern "C"
{
  char* CSharp_Test_ReturnString()
  {    
    QString sv = "QString allocated";
    return strdup((const char*)sv.toAscii());    
  }
}

Won't the CLR free that string for me?  

--
View this message in context: http://mono.1490590.n4.nabble.com/Embedded-Mono-using-DllImport-Internal-and-returning-string-tp4467177p4467177.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list