GSF.IO.BlockAllocatedMemoryStream.Clear C# (CSharp) Method

Clear() public method

Clears the entire BlockAllocatedMemoryStream contents and releases any allocated memory blocks.
public Clear ( ) : void
return void
        public void Clear()
        {
            m_position = 0;
            m_length = 0;
            m_capacity = 0;

            // In the event that an exception occurs, we don't want to have released blocks that are still in this memory stream.
            List<byte[]> blocks = m_blocks;

            m_blocks = new List<byte[]>();

            foreach (var block in blocks)
                MemoryBlockPool.Enqueue(block);
        }