/** <inheritdoc /> */ public byte[] ArrayCopy() { byte[] res = new byte[_mem.Length]; fixed(byte *res0 = res) { PlatformMemoryUtils.CopyMemory(Data, res0, res.Length); } return(res); }
/** <inheritdoc /> */ public byte[] ReadByteArray(int cnt) { int curPos = EnsureReadCapacityAndShift(cnt); byte[] res = new byte[cnt]; fixed(byte *res0 = res) { PlatformMemoryUtils.CopyMemory(Data + curPos, res0, cnt); } return(res); }
/// <summary> /// Copy (write) some data from source and shift the stream forward. /// </summary> /// <param name="src">Source.</param> /// <param name="cnt">Bytes count.</param> private void CopyFromAndShift(byte *src, int cnt) { int curPos = EnsureWriteCapacityAndShift(cnt); PlatformMemoryUtils.CopyMemory(src, Data + curPos, cnt); }
/// <summary> /// Copy (read) some data into destination and shift the stream forward. /// </summary> /// <param name="dest">Destination.</param> /// <param name="cnt">Bytes count.</param> private void CopyToAndShift(byte *dest, int cnt) { int curPos = EnsureReadCapacityAndShift(cnt); PlatformMemoryUtils.CopyMemory(Data + curPos, dest, cnt); }