gmime r1398 - trunk/mono



Author: fejj
Date: Sat Aug 16 06:12:57 2008
New Revision: 1398
URL: http://svn.gnome.org/viewvc/gmime?rev=1398&view=rev

Log:
fixed memory management issue

Modified:
   trunk/mono/InternetAddressList.cs
   trunk/mono/Message.custom

Modified: trunk/mono/InternetAddressList.cs
==============================================================================
--- trunk/mono/InternetAddressList.cs	(original)
+++ trunk/mono/InternetAddressList.cs	Sat Aug 16 06:12:57 2008
@@ -5,6 +5,7 @@
 namespace GMime {
 	public class InternetAddressList : IDisposable, IList {
 		IntPtr list;
+		bool owner;
 		
 #region Native Methods
 		[DllImport("gmime")]
@@ -56,19 +57,20 @@
 		static extern void internet_address_ref (IntPtr raw);
 #endregion
 		
-		public InternetAddressList () : this (internet_address_list_new ())
+		public InternetAddressList () : this (internet_address_list_new (), true)
 		{
 			
 		}
 		
-		public InternetAddressList (IntPtr raw)
+		internal InternetAddressList (IntPtr raw, bool owner)
 		{
+			this.owner = owner;
 			list = raw;
 		}
 		
 		public void Dispose ()
 		{
-			if (list != IntPtr.Zero)
+			if (owner && list != IntPtr.Zero)
 				internet_address_list_destroy (list);
 			
 			list = IntPtr.Zero;
@@ -258,7 +260,7 @@
 			InternetAddressList list = null;
 			
 			if (raw != IntPtr.Zero)
-				list = new InternetAddressList (raw);
+				list = new InternetAddressList (raw, true);
 			
 			GLib.Marshaller.Free (native_str);
 			

Modified: trunk/mono/Message.custom
==============================================================================
--- trunk/mono/Message.custom	(original)
+++ trunk/mono/Message.custom	Sat Aug 16 06:12:57 2008
@@ -5,7 +5,7 @@
 {
 	IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
 
-	return new InternetAddressList (list);
+	return new InternetAddressList (list, false);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]