_handle = handle;
}
+ internal void AddOffset(int offset)
+ {
+ if (_pointer == null)
+ {
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.pointer);
+ }
+ else
+ {
+ _pointer = (void*)((byte*)_pointer + offset);
+ }
+ }
+
[CLSCompliant(false)]
public void* Pointer => _pointer;
}
}
- public abstract MemoryHandle Pin(int offset = 0);
+ public abstract MemoryHandle Pin();
protected internal abstract bool TryGetArray(out ArraySegment<T> arraySegment);
{
if (_index < 0)
{
- memoryHandle = ((OwnedMemory<T>)_object).Pin((_index & RemoveOwnedFlagBitMask) * Unsafe.SizeOf<T>());
+ memoryHandle = ((OwnedMemory<T>)_object).Pin();
+ memoryHandle.AddOffset((_index & RemoveOwnedFlagBitMask) * Unsafe.SizeOf<T>());
}
else if (typeof(T) == typeof(char) && _object is string s)
{
{
if (_index < 0)
{
- memoryHandle = ((OwnedMemory<T>)_object).Pin((_index & RemoveOwnedFlagBitMask) * Unsafe.SizeOf<T>());
+ memoryHandle = ((OwnedMemory<T>)_object).Pin();
+ memoryHandle.AddOffset((_index & RemoveOwnedFlagBitMask) * Unsafe.SizeOf<T>());
}
else if (typeof(T) == typeof(char) && _object is string s)
{