[Mono-bugs] [Bug 62394][Nor] Changed - DllImport broken under Linux

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 4 Aug 2004 13:12:18 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by lupus@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=62394

--- shadow/62394	2004-08-03 23:12:10.000000000 -0400
+++ shadow/62394.tmp.27797	2004-08-04 13:12:18.000000000 -0400
@@ -1,14 +1,14 @@
 Bug#: 62394
 Product: Mono: Runtime
 Version: unspecified
-OS: 
+OS: unknown
 OS Details: RedHat 8
-Status: NEW   
-Resolution: 
-Severity: 
+Status: RESOLVED   
+Resolution: NOTABUG
+Severity: Unknown
 Priority: Normal
 Component: misc
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: michi@zeroc.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
@@ -63,6 +63,22 @@
 The same code works fine under Windows with both .NET and Mono (whether I
 compile it there with Visual C# or mcs makes no difference).
 
 Cheers,
 
 Michi.
+
+------- Additional Comments From lupus@ximian.com  2004-08-04 13:12 -------
+Here is the function prototy from the header:
+BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
+      void
+   );
+It returns a const char*. When you use string as the return type in a
+P/Invoke method it also tells the runtime it needs to free the
+returned pointer after creating a System.String from it. On windows
+the function that frees memory is probably checking that the memory
+was allocated with malloc or whatever and turns into a nop in that case.
+You should declare the method as:
+static extern IntPtr BZ2_bzlibVersion();
+
+and then call Marshal.PtrToStringAnsi (IntPtr); on the result.
+