summary refs log tree commit diff
path: root/crypto/src/openpgp/PgpCompressedDataGenerator.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-11-09 01:13:27 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-11-09 01:13:27 +0700
commita8a17fd70fc8df3ca7402323ad5c4f36b25cb806 (patch)
tree9b276b62885505abbb899d17744b65b912072140 /crypto/src/openpgp/PgpCompressedDataGenerator.cs
parentPrimes improvements (diff)
downloadBouncyCastle.NET-ed25519-a8a17fd70fc8df3ca7402323ad5c4f36b25cb806.tar.xz
Dispose cleanup
- IDisposable for PemReader, PemWriter, IStreamGenerator
Diffstat (limited to 'crypto/src/openpgp/PgpCompressedDataGenerator.cs')
-rw-r--r--crypto/src/openpgp/PgpCompressedDataGenerator.cs45
1 files changed, 28 insertions, 17 deletions
diff --git a/crypto/src/openpgp/PgpCompressedDataGenerator.cs b/crypto/src/openpgp/PgpCompressedDataGenerator.cs
index d13d7402b..271dfac7a 100644
--- a/crypto/src/openpgp/PgpCompressedDataGenerator.cs
+++ b/crypto/src/openpgp/PgpCompressedDataGenerator.cs
@@ -1,7 +1,6 @@
 using System;
 using System.IO;
 
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.IO.Compression;
 using Org.BouncyCastle.Utilities.Zlib;
 
@@ -149,21 +148,33 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 			}
 		}
 
-		/// <summary>Close the compressed object.</summary>summary>
-		public void Close()
-		{
-			if (dOut != null)
-			{
-				if (dOut != pkOut)
-				{
-                    Platform.Dispose(dOut);
-				}
-				dOut = null;
-
-				pkOut.Finish();
-				pkOut.Flush();
-				pkOut = null;
-			}
-		}
+        #region IDisposable
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                if (dOut != null)
+                {
+                    if (dOut != pkOut)
+                    {
+                        dOut.Dispose();
+                    }
+                    dOut = null;
+
+                    pkOut.Finish();
+                    pkOut.Flush();
+                    pkOut = null;
+                }
+            }
+        }
+
+        #endregion
 	}
 }