Exemple #1
0
 private void AllocateBuffer(int size)
 {
     this.m_buffer = SafeBSTRHandle.Allocate((string)null, SecureString.GetAlignedSize(size));
     if (this.m_buffer.IsInvalid)
     {
         throw new OutOfMemoryException();
     }
 }
Exemple #2
0
        private void EnsureCapacity(int capacity)
        {
            if (capacity > 65536)
            {
                throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_Capacity"));
            }
            if (capacity <= this.m_buffer.Length)
            {
                return;
            }
            SafeBSTRHandle target = SafeBSTRHandle.Allocate((string)null, SecureString.GetAlignedSize(capacity));

            if (target.IsInvalid)
            {
                throw new OutOfMemoryException();
            }
            SafeBSTRHandle.Copy(this.m_buffer, target);
            this.m_buffer.Close();
            this.m_buffer = target;
        }