internal UnmanagedSliceStream(USlice slice)
        {
            Contract.Requires(slice.Count == 0 || slice.Data != null);

            m_begin = slice.Data;
            m_size  = slice.Count;
        }
Exemplo n.º 2
0
 public static void CopyUnsafe(USlice dest, byte *src, uint count)
 {
     if (count > 0)
     {
         Contract.Requires(dest.Data != null && src != null);
         CopyUnsafe(dest.Data, src, count);
     }
 }
Exemplo n.º 3
0
 public static void CopyUnsafe(byte *dest, USlice src)
 {
     if (src.Count > 0)
     {
         Contract.Requires(dest != null && src.Data != null);
         CopyUnsafe(dest, src.Data, src.Count);
     }
 }
Exemplo n.º 4
0
        /// <summary>Copy the content of an unmanaged slice of memory, using a specific alignment</summary>
        /// <param name="data">Slice of unmanaged memory to copy</param>
        /// <param name="align">Required memory alignment. MUST BE A POWER OF 2 !</param>
        /// <returns>New slice pointing to the copied bytes in the allocator memory. The start address should be aligned to either 4 or 8 bytes, depending on the platform architecture.</returns>
        private USlice Memoize(USlice data, uint align)
        {
            if (data.Count == 0)
            {
                return(default(USlice));
            }
            byte *ptr = Allocate(data.Count, align);

            if (ptr == null)
            {
                throw new OutOfMemoryException();
            }
            UnmanagedHelpers.CopyUnsafe(ptr, data);
            return(new USlice(ptr, data.Count));
        }
Exemplo n.º 5
0
        public void Set(USlice source)
        {
            m_count = 0;
            if (source.Count > 0)
            {
                if (source.Data == null)
                {
                    ThrowInvalidSource();
                }

                var ptr = AllocateInternal(source.Count, zeroed: false);
                Contract.Assert(ptr != null);
                UnmanagedHelpers.CopyUnsafe(ptr, source);
            }
        }
Exemplo n.º 6
0
        public void Append(USlice source)
        {
            if (source.Count == 0)
            {
                return;
            }
            if (source.Data == null)
            {
                ThrowInvalidSource();
            }

            byte *ptr = AllocateInternal(source.Count, zeroed: false);

            Contract.Assert(ptr != null);
            UnmanagedHelpers.CopyUnsafe(ptr, source);
        }
Exemplo n.º 7
0
 public static int ComputeHashCode(ref USlice slice)
 {
     if (slice.Data == null)
         return(0); }
Exemplo n.º 8
0
 /// <summary>Copy the content of an unmanaged slice of memory, starting at an aligned address</summary>
 /// <param name="data">Slice of unmanaged memory to copy</param>
 /// <returns>New slice pointing to the copied bytes in the allocator memory. The start address should be aligned to either 4 or 8 bytes, depending on the platform architecture.</returns>
 public USlice MemoizeAligned(USlice data)
 {
     return(Memoize(data, m_alignment));
 }
Exemplo n.º 9
0
 /// <summary>Copy the content of an unmanaged slice of memory</summary>
 /// <param name="data">Slice of unmanaged memory to copy</param>
 /// <returns>New slice pointing to the copied bytes in the allocator memory</returns>
 public USlice Memoize(USlice data)
 {
     return(Memoize(data, 1));
 }
Exemplo n.º 10
0
 public USliceDebugView(USlice slice)
 {
     m_slice = slice;
 }
Exemplo n.º 11
0
 public UnmanagedSliceBuilder(USlice slice)
     : this(slice.Data, slice.Count)
 {
 }
Exemplo n.º 12
0
 /// <summary>Creates a reader on a byte array</summary>
 public static UnmanagedSliceReader FromSlice(USlice slice)
 {
     return(new UnmanagedSliceReader(slice.Data, slice.Count));
 }