internal UnmanagedSliceStream(USlice slice) { Contract.Requires(slice.Count == 0 || slice.Data != null); m_begin = slice.Data; m_size = slice.Count; }
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); } }
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); } }
/// <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)); }
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); } }
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); }
public static int ComputeHashCode(ref USlice slice) { if (slice.Data == null) return(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)); }
/// <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)); }
public USliceDebugView(USlice slice) { m_slice = slice; }
public UnmanagedSliceBuilder(USlice slice) : this(slice.Data, slice.Count) { }
/// <summary>Creates a reader on a byte array</summary> public static UnmanagedSliceReader FromSlice(USlice slice) { return(new UnmanagedSliceReader(slice.Data, slice.Count)); }