示例#1
0
        /// <summary>
        /// Releases the unmanaged resources used by this <see cref="BroVector"/> object and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!m_disposed)
            {
                try
                {
#if USE_SAFE_HANDLES
                    if ((object)m_vectorPtr != null && !m_vectorPtr.IsInvalid())
                    {
                        m_vectorPtr.Dispose();
                    }
#else
                    if (m_vectorPtr != IntPtr.Zero)
                    {
                        BroApi.bro_vector_free(m_vectorPtr);
                        m_vectorPtr = IntPtr.Zero;
                    }
#endif
                }
                finally
                {
                    m_disposed = true;  // Prevent duplicate dispose.
                }
            }
        }
示例#2
0
        /// <summary>
        /// Creates a new <see cref="BroVector"/>.
        /// </summary>
        /// <exception cref="OutOfMemoryException">Failed to create Bro vector.</exception>
        public BroVector()
        {
            m_vectorPtr = BroApi.bro_vector_new();

            if (m_vectorPtr.IsInvalid())
            {
                throw new OutOfMemoryException("Failed to create Bro vector.");
            }
        }
示例#3
0
        /// <summary>
        /// Removes all items from this <see cref="BroVector"/>.
        /// </summary>
        /// <exception cref="ObjectDisposedException">Cannot clear, <see cref="BroVector"/> is disposed.</exception>
        public void Clear()
        {
            if (m_vectorPtr.IsInvalid())
            {
                throw new ObjectDisposedException("Cannot clear items, Bro vector is disposed.");
            }

#if USE_SAFE_HANDLES
            m_vectorPtr.Dispose();
#else
            BroApi.bro_vector_free(m_vectorPtr);
#endif
            m_vectorPtr = BroApi.bro_vector_new();
        }
示例#4
0
        // Create new BroVector from an existing source vector - have to clone source vector since we don't own it
#if USE_SAFE_HANDLES
        internal BroVector(BroVectorPtr sourceVectorPtr)