internal BufferList Clone(int index, int segmentOffset, int length) { var target = new BufferList(); var rest = length; var segments = m_List; for (var i = index; i < segments.Count; i++) { var pair = segments[i]; var segment = pair; var offset = segment.Offset; var thisLen = segment.Count; if (i == index) { offset = segmentOffset; thisLen = segment.Count - (segmentOffset - segment.Offset); } thisLen = Math.Min(thisLen, rest); target.Add(new ArraySegment <byte>(segment.Array, offset, thisLen)); rest -= thisLen; if (rest <= 0) { break; } } return(target); }
private void PushResetData(ArraySegment <byte> raw, int rest) { var segment = new ArraySegment <byte>(raw.Array, raw.Offset + raw.Count - rest, rest); m_ReceiveCache.Add(segment); }