示例#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>
        /// 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();
        }