Game Development Reference
In-Depth Information
byte[] destinationData = new byte[dataLength];
for (int index = 0; index < dataLength; index++)
{
sourceData[index] = (byte)index;
}
UnsafeCopy(sourceData, 0, destinationData, 0, dataLength);
Console.WriteLine(“The first 15 elements are:”);
for (int index = 0; index < 15; index++)
{
Console.Write(destinationData[index] + “ “);
}
Console.WriteLine(“\n”);
}
static unsafe void UnsafeCopy(byte[] source,
int sourceIndex,
byte[] destination,
int destinationIndex,
int count)
{
Debug.Assert(source != null);
Debug.Assert(sourceIndex >= 0);
Debug.Assert(destination != null);
Debug.Assert(destinationIndex >= 0);
Debug.Assert(!(source.Length - sourceIndex < count));
Debug.Assert(!(destination.Length - destinationIndex < count));
unchecked
{
int countDiv = count / 4;
int countMod = count % 4;
fixed (byte* sourcePtr = source, destinationPtr = destination)
{
byte* sourceByte = sourcePtr;
byte* destinationByte = destinationPtr;
Search Nedrilad ::




Custom Search