mirror of
https://github.com/crskycode/GARbro.git
synced 2024-10-23 07:38:16 +08:00
call Dispose on IEnumerator<T> where appropriate.
This commit is contained in:
parent
60fdc6e70f
commit
1749b93d7a
@ -2,7 +2,7 @@
|
||||
//! \date Sun Sep 07 06:50:11 2014
|
||||
//! \brief KiriKiri Cx encryption scheme implementation.
|
||||
//
|
||||
// Copyright (C) 2014-2015 by morkt
|
||||
// Copyright (C) 2014-2016 by morkt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
@ -131,8 +131,6 @@ namespace GameRes.Formats.KiriKiri
|
||||
if (0 == key3)
|
||||
key3 = 1;
|
||||
|
||||
// Trace.WriteLine (string.Format ("[offset:{3:x4}] [key1:{0:x4}] [key2:{1:x4}] [key3:{2:x6}]", key1, key2, key3, offset));
|
||||
|
||||
if ((key2 >= offset) && (key2 < offset + count))
|
||||
buffer[pos + key2 - offset] ^= (byte)(ret.Item1 >> 16);
|
||||
|
||||
@ -405,7 +403,8 @@ namespace GameRes.Formats.KiriKiri
|
||||
public uint Execute (uint hash)
|
||||
{
|
||||
var context = new Context();
|
||||
var iterator = m_code.GetEnumerator();
|
||||
using (var iterator = m_code.GetEnumerator())
|
||||
{
|
||||
uint immed = 0;
|
||||
while (iterator.MoveNext())
|
||||
{
|
||||
@ -466,6 +465,7 @@ namespace GameRes.Formats.KiriKiri
|
||||
throw new CxProgramException ("Invalid bytecode in CxEncryption program");
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new CxProgramException ("CxEncryption program without RETN bytecode");
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user