Repository: dotnet/aspnetcore
File: src/Shared/HttpSys/RequestProcessing/NativeRequestContext.cs (C#)

Code before:

    private SocketAddress? GetEndPoint(bool localEndpoint)
    {
        if (PermanentlyPinned)
        {
            return GetEndPointHelper(localEndpoint, _nativeRequest, (byte*)0);
        }
        else
        {
            fixed (byte* pMemoryBlob = _backingBuffer.Memory.Span)
            {
                var request = (HTTP_REQUEST_V1*)(pMemoryBlob + _bufferAlignment);
                return GetEndPointHelper(localEndpoint, request, pMemoryBlob);
            }
        }
    }

    private SocketAddress? GetEndPointHelper(bool localEndpoint, HTTP_REQUEST_V1* request, byte* pMemoryBlob)
    {
        var source = localEndpoint ? request->Address.pLocalAddress : request->Address.pRemoteAddress;

        if (source == null)
        {
            return null;
        }

        return SocketAddress.CopyOutAddress(source);
    }

    internal uint GetChunks(ref int dataChunkIndex, ref uint dataChunkOffset, byte[] buffer, int offset, int size)
    {
        // Return value.
        if (PermanentlyPinned)
        {
            return GetChunksHelper(ref dataChunkIndex, ref dataChunkOffset, buffer, offset, size, 0, _nativeRequest);
        }
        else
        {
            fixed (byte* pMemoryBlob = _backingBuffer.Memory.Span)
            {
                var request = (HTTP_REQUEST_V1*)(pMemoryBlob + _bufferAlignment);
                var fixup = pMemoryBlob - (byte*)_originalBufferAddress;
                return GetChunksHelper(ref dataChunkIndex, ref dataChunkOffset, buffer, offset, size, fixup, request);
            }
        }
    }

    private uint GetChunksHelper(ref int dataChunkIndex, ref uint dataChunkOffset, byte[] buffer, int offset, int size, long fixup, HTTP_REQUEST_V1* request)
    {
        uint dataRead = 0;


Review comment (suggestion):
Is it really ok to delete this address fixup? It seems to be required given the buffer gymnastics employed by this type.

(The other places in this file use `long fixup` argument instead of `byte* pMemoryBlob` argument that is a bit easier to understand in my opinion.)

Code after:
    }

    private SocketAddress? GetEndPoint(bool localEndpoint)
    {
        if (PermanentlyPinned)
        {
            return GetEndPointHelper(localEndpoint, _nativeRequest, (byte*)0);
        }
        else
        {
            fixed (byte* pMemoryBlob = _backingBuffer.Memory.Span)
            {
                var request = (HTTP_REQUEST_V1*)(pMemoryBlob + _bufferAlignment);
                return GetEndPointHelper(localEndpoint, request, pMemoryBlob);
            }
        }
    }

    private SocketAddress? GetEndPointHelper(bool localEndpoint, HTTP_REQUEST_V1* request, byte* pMemoryBlob)
    {
        var source = localEndpoint ? (byte*)request->Address.pLocalAddress : (byte*)request->Address.pRemoteAddress;

        if (source == null)
        {
            return null;
        }

        var address = (SOCKADDR*)(pMemoryBlob + _bufferAlignment - (byte*)_originalBufferAddress + source);
        return SocketAddress.CopyOutAddress(address);
    }

    internal uint GetChunks(ref int dataChunkIndex, ref uint dataChunkOffset, byte[] buffer, int offset, int size)
    {
        // Return value.
        if (PermanentlyPinned)
        {
            return GetChunksHelper(ref dataChunkIndex, ref dataChunkOffset, buffer, offset, size, 0, _nativeRequest);
        }
        else
        {
            fixed (byte* pMemoryBlob = _backingBuffer.Memory.Span)
            {
                var request = (HTTP_REQUEST_V1*)(pMemoryBlob + _bufferAlignment);
                var fixup = pMemoryBlob - (byte*)_originalBufferAddress;
                return GetChunksHelper(ref dataChunkIndex, ref dataChunkOffset, buffer, offset, size, fixup, request);
            }
        }
    }

    private uint GetChunksHelper(ref int dataChunkIndex, ref uint dataChunkOffset, byte[] buffer, int offset, int size, long fixup, HTTP_REQUEST_V1* request)
    {