/// <summary> /// Releases the unmanaged resources used by this <see cref="BroPacket"/> 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_packetPtr != null && !m_packetPtr.IsInvalid()) { m_packetPtr.Dispose(); } #else if (m_packetPtr != IntPtr.Zero) { BroApi.bro_packet_free(m_packetPtr); m_packetPtr = IntPtr.Zero; } #endif } finally { m_disposed = true; // Prevent duplicate dispose. } } }