[Monodevelop-patches-list] r1647 - in trunk/MonoDevelop/src/Libraries: MonoDevelop.Core MonoDevelop.Core/Services MonoDevelop.Gui.Utils MonoDevelop.Gui.Utils/VFS

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Wed May 26 18:18:51 EDT 2004


Author: tberman
Date: 2004-05-26 18:18:50 -0400 (Wed, 26 May 2004)
New Revision: 1647

Modified:
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/ChangeLog
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/Services/GettextCatalog.cs
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/ChangeLog
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/VFS/Vfs.cs
Log:
fix string marshalling for new runtime changes


Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/ChangeLog	2004-05-26 12:36:27 UTC (rev 1646)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/ChangeLog	2004-05-26 22:18:50 UTC (rev 1647)
@@ -1,3 +1,8 @@
+2004-05-26  Todd Berman  <tberman at sevenl.net>
+
+	* Services/GettextCatalog.cs: change to string marshaling to prevent
+	leaks.
+
 2004-04-04  Todd Berman  <tberman at sevenl.net>
 
 	* AddIns/AddInTreeSingleton.cs: Change to .addin.xml to allow gettext

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/Services/GettextCatalog.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/Services/GettextCatalog.cs	2004-05-26 12:36:27 UTC (rev 1646)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/Services/GettextCatalog.cs	2004-05-26 22:18:50 UTC (rev 1647)
@@ -23,6 +23,7 @@
  *     be picked up by update-po.
  */
 
+using System;
 using System.Runtime.InteropServices;
 
 using MonoDevelop.Core.Services;
@@ -43,15 +44,15 @@
 		}
 	
 		[DllImport ("libmonodevelop")]
-		private static extern string intl_get_string (string str);
+		private static extern IntPtr intl_get_string (string str);
 	
 		public static string GetString (string str)
 		{
-			return intl_get_string (str);
+			return Marshal.PtrToStringAnsi (intl_get_string (str));
 		}
 	
 		[DllImport ("libmonodevelop")]
-		private static extern string intl_get_plural_string (string singular,
+		private static extern IntPtr intl_get_plural_string (string singular,
 								     string plural,
 								     int n);
 	
@@ -59,7 +60,7 @@
 			    	 	              string plural,
 					              int n)
 		{
-			return intl_get_plural_string (singular, plural, n);
+			return Marshal.PtrToStringAnsi (intl_get_plural_string (singular, plural, n));
 		}
 	}
 }

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/ChangeLog	2004-05-26 12:36:27 UTC (rev 1646)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/ChangeLog	2004-05-26 22:18:50 UTC (rev 1647)
@@ -1,3 +1,7 @@
+2004-05-26  Todd Berman  <tberman at sevenl.net>
+
+	* VFS/Vfs.cs: change string marshalling to make things not leak.
+
 2004-04-12  Kristian Rietveld  <kris at gtk.org>
 
 	* FileIcons/FileIconLoader.cs: if LookupIcon returns an empty string,

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/VFS/Vfs.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/VFS/Vfs.cs	2004-05-26 12:36:27 UTC (rev 1646)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/VFS/Vfs.cs	2004-05-26 22:18:50 UTC (rev 1647)
@@ -20,17 +20,17 @@
 		static extern bool gnome_vfs_shutdown ();
 		
 		[DllImport ("gnomevfs-2")]
-		static extern string gnome_vfs_get_mime_type (string uri);
+		static extern IntPtr gnome_vfs_get_mime_type (string uri);
 		
 		[DllImport ("gnomevfs-2")]
-		static extern string gnome_vfs_get_mime_type_for_data (string data, int length);
+		static extern IntPtr gnome_vfs_get_mime_type_for_data (string data, int length);
 		
 		[DllImport ("gnomevfs-2")]
-		static extern string gnome_vfs_mime_get_icon (string mime_type);
+		static extern IntPtr gnome_vfs_mime_get_icon (string mime_type);
 		
 		[DllImport ("gnomevfs-2")]
 		static extern bool gnome_vfs_mime_type_is_known (string mime_type);
-		
+
 		private Vfs ()
 		{
 		}
@@ -43,17 +43,17 @@
 		
 		public static string GetIcon (string mimetype)
 		{
-			return gnome_vfs_mime_get_icon (mimetype);
+			return GLib.Marshaller.PtrToStringGFree (gnome_vfs_mime_get_icon (mimetype));
 		}
 		
 		public static string GetMimeType (string filename)
 		{
-			return gnome_vfs_get_mime_type (filename);
+			return GLib.Marshaller.PtrToStringGFree (gnome_vfs_get_mime_type (filename));
 		}
 		
 		public static string GetMimeTypeFromData (string data)
 		{
-			return gnome_vfs_get_mime_type_for_data (data, data.Length);
+			return GLib.Marshaller.PtrToStringGFree (gnome_vfs_get_mime_type_for_data (data, data.Length));
 		}
 		
 		public static bool IsKnownType (string mimetype)




More information about the Monodevelop-patches-list mailing list