call Dispose on IEnumerator<T> where appropriate.

This commit is contained in:
morkt
2016-03-05 17:22:14 +04:00
parent 60fdc6e70f
commit 1749b93d7a
2 changed files with 71 additions and 56 deletions

View File

@@ -44,7 +44,7 @@ namespace GameRes.Compression
public int FrameInitPos { get; set; }
}
internal sealed class LzssCoroutine : LzssSettings
internal sealed class LzssCoroutine : LzssSettings, IDisposable
{
byte[] m_buffer;
int m_offset;
@@ -122,6 +122,20 @@ namespace GameRes.Compression
}
}
}
#region IDisposable Members
bool _disposed = false;
public void Dispose ()
{
if (!_disposed)
{
if (m_unpack != null)
m_unpack.Dispose();
_disposed = true;
}
GC.SuppressFinalize (this);
}
#endregion
}
public class LzssStream : Stream
@@ -193,6 +207,7 @@ namespace GameRes.Compression
{
if (m_should_dispose && disposing)
m_input.Dispose();
m_reader.Dispose();
m_disposed = true;
base.Dispose (disposing);
}