예제 #1
0
        unsafe public override void Run(int count, int batch)
        {
            //var a1 = new long[] { long.MinValue, 0, long.MaxValue };
            //var buff = new byte[24];
            //var a2 = new long[3];

            var a1   = new char[] { '1', '2', '3' };
            var buff = new byte[24];
            var a2   = new char[3];

            for (int i = 0; i < count; i++)
            {
                fixed(char *p_a1 = &a1[0])
                fixed(byte *p_buff = &buff[0])
                fixed(char *p_a2   = &a2[0])
                {
                    Unsafe_Utilities.Memcpy(p_buff, (byte *)p_a1, 24);
                    Unsafe_Utilities.Memcpy((byte *)p_a2, p_buff, 24);
                }

                //for (int j = 0; j < a1.Length; j++)
                //{
                //    Array.Copy(BitConverter.GetBytes(a1[j]), 0, buff, j * 8, 8);
                //    //a2[j] = BitConverter.ToInt64(buff, j * 8);
                //}
                //for (int j = 0; j < a1.Length; j++)
                //{
                //    a2[j] = BitConverter.ToInt64(buff, j * 8);
                //}
            }
        }
예제 #2
0
 unsafe public void To_Buffer(Guid[] values, int end_Index, byte[] buffer, int buffer_offset)
 {
     fixed (Guid* p_values = &values[0])
     fixed (byte* p_buffer = &buffer[0])
     {
         Unsafe_Utilities.Memcpy(p_buffer + buffer_offset, (byte*)p_values, 16 * end_Index);
     }
 }
예제 #3
0
 public unsafe void To_Buffer(long[] values, int end_Index, byte[] buffer, int buffer_offset)
 {
     fixed (long* p_Pointers = &values[0])
     fixed (byte* p_buff = &buffer[0])
     {
         byte* shifted = p_buff + buffer_offset;
         Unsafe_Utilities.Memcpy(shifted, (byte*)p_Pointers, 8 * (end_Index + 1));
     }
 }
예제 #4
0
 unsafe public int[] Get_Instances(byte[] value, int startIndex, int length)
 {
     int[] result = new int[length];
     fixed (int* p_Pointers = &result[0])
     fixed (byte* p_buff = &value[0])
     {
         byte* shifted = p_buff + startIndex;
         Unsafe_Utilities.Memcpy((byte*)p_Pointers, shifted, 4 * length);
     }
     return result;
 }
예제 #5
0
        unsafe public Guid[] Get_Instances(byte[] buffer, int startIndex, int length)
        {
            Guid[] result = new Guid[length];

            fixed (Guid* p_result = &result[0])
            fixed (byte* p_buffer = &buffer[0])
            {
                Unsafe_Utilities.Memcpy((byte*)p_result, p_buffer, 16 * length);
            }

            return result;
        }