protected void CheckIndex0(int index, int fieldLength) { if (MathUtil.IsOutOfBounds(index, fieldLength, this.Capacity)) { ThrowHelper.ThrowIndexOutOfRangeException($"index: {index}, length: {fieldLength} (expected: range(0, {this.Capacity}))"); } }
IByteBuffer CheckIndex(int index) { if ((uint)index > 0u) // != 0 { ThrowHelper.ThrowIndexOutOfRangeException(); } return(this); }
protected void CheckDstIndex(int index, int length, int dstIndex, int dstCapacity) { this.CheckIndex(index, length); if (MathUtil.IsOutOfBounds(dstIndex, length, dstCapacity)) { ThrowHelper.ThrowIndexOutOfRangeException($"dstIndex: {dstIndex}, length: {length} (expected: range(0, {dstCapacity}))"); } }
void CheckLength0(int length) { if ((uint)length > SharedConstants.TooBigOrNegative) { ThrowHelper.ThrowArgumentException_PositiveOrZero(length, ExceptionArgument.length); } if ((uint)length > 0u) { ThrowHelper.ThrowIndexOutOfRangeException(); } }
void CheckLength0(int length) { if (length < 0) { ThrowHelper.ThrowArgumentException_PositiveOrZero(length, ExceptionArgument.length); } if (length > 0) { ThrowHelper.ThrowIndexOutOfRangeException(); } }
void CheckIndex0(int index, int length) { if (length < 0) { ThrowHelper.ThrowArgumentException_PositiveOrZero(length, ExceptionArgument.length); } if ((uint)index > 0u || length > 0) { ThrowHelper.ThrowIndexOutOfRangeException(); } }
public IByteBuffer EnsureWritable(int minWritableBytes) { if ((uint)minWritableBytes > SharedConstants.TooBigOrNegative) { ThrowHelper.ThrowArgumentException_PositiveOrZero(minWritableBytes, ExceptionArgument.minWritableBytes); } if (minWritableBytes != 0) { ThrowHelper.ThrowIndexOutOfRangeException(); } return(this); }
public IByteBuffer EnsureWritable(int minWritableBytes) { if (minWritableBytes < 0) { ThrowHelper.ThrowArgumentException_PositiveOrZero(minWritableBytes, ExceptionArgument.minWritableBytes); } if (minWritableBytes != 0) { ThrowHelper.ThrowIndexOutOfRangeException(); } return(this); }
internal void Reallocate(PooledByteBuffer <T> buf, int newCapacity, bool freeOldMemory) { if (/*newCapacity < 0 || */ (uint)newCapacity > (uint)buf.MaxCapacity) { ThrowHelper.ThrowIndexOutOfRangeException(); } int oldCapacity = buf.Length; if (oldCapacity == newCapacity) { return; } PoolChunk <T> oldChunk = buf.Chunk; long oldHandle = buf.Handle; T oldMemory = buf.Memory; int oldOffset = buf.Offset; int oldMaxLength = buf.MaxLength; // This does not touch buf's reader/writer indices Allocate(Parent.ThreadCache <T>(), buf, newCapacity); int bytesToCopy; if (newCapacity > oldCapacity) { bytesToCopy = oldCapacity; } else { buf.TrimIndicesToCapacity(newCapacity); bytesToCopy = newCapacity; } MemoryCopy(oldMemory, oldOffset, buf.Memory, buf.Offset, bytesToCopy); if (freeOldMemory) { Free(oldChunk, oldHandle, oldMaxLength, buf.Cache); } }