Пример #1
0
        /// <summary>
        /// Releases the unmanaged resources used by this <see cref="BroRecord"/> 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_recordPtr != null && !m_recordPtr.IsInvalid())
                    {
                        m_recordPtr.Dispose();
                    }
#else
                    if (m_recordPtr != IntPtr.Zero)
                    {
                        BroApi.bro_record_free(m_recordPtr);
                        m_recordPtr = IntPtr.Zero;
                    }
#endif
                }
                finally
                {
                    m_disposed = true;  // Prevent duplicate dispose.
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new <see cref="BroRecord"/>.
        /// </summary>
        /// <exception cref="OutOfMemoryException">Failed to create Bro record.</exception>
        public BroRecord()
        {
            m_recordPtr = BroApi.bro_record_new();

            if (m_recordPtr.IsInvalid())
            {
                throw new OutOfMemoryException("Failed to create Bro record.");
            }
        }
Пример #3
0
        /// <summary>
        /// Removes all fields from this <see cref="BroRecord"/>.
        /// </summary>
        /// <exception cref="ObjectDisposedException">Cannot clear, <see cref="BroRecord"/> is disposed.</exception>
        public void Clear()
        {
            if (m_recordPtr.IsInvalid())
            {
                throw new ObjectDisposedException("Cannot clear items, Bro record is disposed.");
            }

#if USE_SAFE_HANDLES
            m_recordPtr.Dispose();
#else
            BroApi.bro_record_free(m_recordPtr);
#endif
            m_recordPtr = BroApi.bro_record_new();
        }
Пример #4
0
        // Create new BroRecord from an existing source record - have to clone source record since we don't own it
#if USE_SAFE_HANDLES
        internal BroRecord(BroRecordPtr sourceRecordPtr)