dotgnu-pnet-commits
[Top][All Lists]
Advanced

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

[dotgnu-pnet-commits] pnetlib ./ChangeLog DotGNU.SSL/GNUTLS.cs


From: Deryk Robosson
Subject: [dotgnu-pnet-commits] pnetlib ./ChangeLog DotGNU.SSL/GNUTLS.cs
Date: Sat, 13 May 2006 06:25:55 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Branch:         
Changes by:     Deryk Robosson <address@hidden> 06/05/13 06:25:55

Modified files:
        .              : ChangeLog 
        DotGNU.SSL     : GNUTLS.cs 

Log message:
        implement finalizers for IDisposable classes

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2398&tr2=1.2399&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/DotGNU.SSL/GNUTLS.cs.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2398 pnetlib/ChangeLog:1.2399
--- pnetlib/ChangeLog:1.2398    Sat May 13 04:45:04 2006
+++ pnetlib/ChangeLog   Sat May 13 06:25:55 2006
@@ -1,7 +1,8 @@
 2006-05-13  Deryk Robosson  <address@hidden>
 
-       * DotGnu.Images/JpegLib.cs: Add [NonSerializedAttribute] tag where
+       * DotGNU.Images/JpegLib.cs: Add [NonSerializedAttribute] tag where
        required.
+       * DotGNU.SSL/GNUTLS.cs: Implement finalizers for IDisposable classes.
 
 2006-05-10  Deryk Robosson  <address@hidden>
 
Index: pnetlib/DotGNU.SSL/GNUTLS.cs
diff -u pnetlib/DotGNU.SSL/GNUTLS.cs:1.4 pnetlib/DotGNU.SSL/GNUTLS.cs:1.5
--- pnetlib/DotGNU.SSL/GNUTLS.cs:1.4    Mon May  8 10:37:26 2006
+++ pnetlib/DotGNU.SSL/GNUTLS.cs        Sat May 13 06:25:55 2006
@@ -76,10 +76,20 @@
        {
                // Internal state.
                protected IntPtr cred;
+               private bool isDisposed;
 
                // Constructor.
                protected GNUTLSCredentials() {}
 
+               // Finalizer.
+               ~GNUTLSCredentials()
+               {
+                       if(isDisposed == false)
+                       {
+                               Dispose();
+                       }
+               }
+
                // Get the credential pointer.
                public IntPtr Cred
                                {
@@ -96,6 +106,7 @@
                public virtual void Dispose()
                                {
                                        cred = IntPtr.Zero;
+                                       isDisposed = true;
                                }
 
        }; // class GNUTLSCredentials
@@ -103,6 +114,8 @@
        // Credentials object that is based on a certificate/private key pair.
        private sealed class GNUTLSCertificateCredentials : GNUTLSCredentials
        {
+               private bool isDisposed;
+
                // Constructor.
                public GNUTLSCertificateCredentials(byte[] certificate, byte[] 
key)
                                {
@@ -115,6 +128,15 @@
                                        k.Free();
                                }
 
+               // Finalizer.
+               ~GNUTLSCertificateCredentials()
+                               {
+                                       if(isDisposed == false)
+                                       {
+                                               Dispose();
+                                       }
+                               }
+
                // Get the credential type.
                public override int CredType
                                {
@@ -139,12 +161,23 @@
        // Credentials object for anonymous access.
        private sealed class GNUTLSAnonCredentials : GNUTLSCredentials
        {
+               private bool isDisposed;
+
                // Constructor.
                public GNUTLSAnonCredentials()
                                {
                                        
gnutls_certificate_allocate_credentials(out cred);
                                }
 
+               // Finalizer.
+               ~GNUTLSAnonCredentials()
+                               {
+                                       if(isDisposed == false)
+                                       {
+                                               Dispose();
+                                       }
+                               }
+
                // Get the credential type.
                public override int CredType
                                {
@@ -162,6 +195,7 @@
                                                
gnutls_certificate_free_credentials(cred);
                                                base.Dispose();
                                        }
+                                       isDisposed = true;
                                }
 
        }; // class GNUTLSAnonCredentials




reply via email to

[Prev in Thread] Current Thread [Next in Thread]