CopyOverlapped function defined in GameRes.Utitlity now.

CopyOverlapped copies ranges within array the same way standard C
function memcpy does (that is, ignoring potential region overlapping).
This commit is contained in:
morkt
2014-08-25 15:04:26 +04:00
parent 01464389d2
commit b0f621e8ab
3 changed files with 18 additions and 32 deletions

View File

@@ -399,26 +399,12 @@ namespace GameRes.Formats.Majiro
shift *= 3;
if (shift >= 0 || data_pos+shift < 0)
throw new InvalidFormatException();
CopyOverlapped (m_data, data_pos+shift, data_pos, count);
Binary.CopyOverlapped (m_data, data_pos+shift, data_pos, count);
data_pos += count;
}
}
}
static internal void CopyOverlapped (byte[] data, int src, int dst, int count)
{
int preceding = dst-src;
while (count > 0)
{
if (preceding > count)
preceding = count;
Array.Copy (data, src, data, dst, preceding);
src = dst;
dst += preceding;
count -= preceding;
}
}
#region IDisposable Members
bool disposed = false;
@@ -575,7 +561,7 @@ namespace GameRes.Formats.Majiro
shift -= shift_row;
if (shift >= 0 || data_pos+shift < 0)
throw new InvalidFormatException();
RctFormat.Reader.CopyOverlapped (m_data, data_pos+shift, data_pos, count);
Binary.CopyOverlapped (m_data, data_pos+shift, data_pos, count);
data_pos += count;
}
}