Ejemplo n.º 1
0
        static void BufferLifetime(ReadOnlyBuffer <byte> buffer)
        {
            var array = buffer.ToArray();

            using (var handle = buffer.Retain())
                using (var pinned = buffer.Pin())
                {
                    unsafe
                    {
                        var p = (byte *)pinned.PinnedPointer;
                        Assert.True(null != p);
                        for (int i = 0; i < buffer.Length; i++)
                        {
                            Assert.Equal(array[i], p[i]);
                        }
                    }
                }
        }