[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnetlib/DotGNU.SSL GNUTLS.cs
From: |
Deryk Robosson |
Subject: |
[dotgnu-pnet-commits] pnetlib/DotGNU.SSL GNUTLS.cs |
Date: |
Sat, 13 May 2006 06:46:08 +0000 |
CVSROOT: /sources/dotgnu-pnet
Module name: pnetlib
Branch:
Changes by: Deryk Robosson <address@hidden> 06/05/13 06:46:08
Modified files:
DotGNU.SSL : GNUTLS.cs
Log message:
gnutls_datum had managed resources that should be freed when required
(yes, even for structs)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/DotGNU.SSL/GNUTLS.cs.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: pnetlib/DotGNU.SSL/GNUTLS.cs
diff -u pnetlib/DotGNU.SSL/GNUTLS.cs:1.5 pnetlib/DotGNU.SSL/GNUTLS.cs:1.6
--- pnetlib/DotGNU.SSL/GNUTLS.cs:1.5 Sat May 13 06:25:55 2006
+++ pnetlib/DotGNU.SSL/GNUTLS.cs Sat May 13 06:46:08 2006
@@ -681,10 +681,11 @@
ref gnutls_datum key, Int type);
[StructLayout(LayoutKind.Sequential)]
- private struct gnutls_datum
+ private struct gnutls_datum : IDisposable
{
public IntPtr data;
public UInt size;
+ private bool isDisposed;
// Constructor.
public gnutls_datum(byte[] value)
@@ -694,6 +695,27 @@
size = (UInt)(value.Length);
}
+ // Finalizer.
+ // structs do not normally have finalizers, however
+ // this one has unmanaged resources that needs to be freed
+ ~gnutls_datum()
+ {
+ if(isDisposed == false)
+ {
+ Free();
+ }
+ }
+
+ // IDisposable interface because we have unmanaged resources
+ public void Dispose()
+ {
+ if(isDisposed == false)
+ {
+ Free();
+ }
+ isDisposed = true;
+ }
+
// Free the data in this object.
public void Free()
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnetlib/DotGNU.SSL GNUTLS.cs,
Deryk Robosson <=