Example #1
0
        public void DuplicateRelease()
        {
            IArrayBuffer <byte> buf = this.allocator.Buffer(8);

            Assert.Equal(1, buf.ReferenceCount);
            Assert.True(buf.Duplicate().Release());
            Assert.Equal(0, buf.ReferenceCount);
        }
Example #2
0
        public static IArrayBuffer <byte> CopiedBuffer(IArrayBuffer <byte> buffer)
        {
            Contract.Requires(buffer != null);

            int length = buffer.ReadableCount;

            if (length == 0)
            {
                return(Empty);
            }
            var copy = new byte[length];

            // Duplicate the buffer so we do not adjust our position during our get operation
            IArrayBuffer <byte> duplicate = buffer.Duplicate();

            duplicate.Get(0, copy);
            return(WrappedBuffer(copy));
        }