Re: [Rubydotnet-developer] Dead in the water
Status: Alpha
Brought to you by:
thomas
From: Tim S. <ti...@ih...> - 2004-01-08 11:02:59
|
On Wed, Oct 08, 2003 at 04:31:17PM +0200, Thomas Sondergaard wrote: [...] > Nothing much has happened on my end. I have started porting my extension > to use C# with P/Invoke instead of C++ with managed extensions so it > will be easier to port between Microsoft, Mono and dotgnu. I am > currently trying to figure out how safe it is to use P/Invoke with the > ruby API. I am especially concerned about the ruby garbage collector, so > I am trying to understand how it works. [...] Sorry for replying so late to this thread... I believe[*] that if a C function returns a char* and you tell .NET that it returns a string, .NET takes responsibility for freeing the buffer. This is bad if the char* was an RSTRING(s)->ptr. Instead, have it return a System.IntPtr and then use string s = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptr); Similar issues exist with other types. [*] This is my interpretation of the .NET documentation. |