diff --git a/Collection/LinkedList.mqh b/Collection/LinkedList.mqh index 809c48d..fa602ba 100644 --- a/Collection/LinkedList.mqh +++ b/Collection/LinkedList.mqh @@ -82,16 +82,15 @@ public: template LinkedListBase::~LinkedListBase() { - if(m_owned) + LinkedNode*n=m_head.next(); + while(n!=m_tail) { - LinkedNode*n=m_head.next(); - while(n!=m_tail) - { - LinkedNode*tempNode=n.next(); - SafeDelete(n); - n=tempNode; - } + LinkedNode*tempNode=n.next(); + if(!m_owned) n.release(); + SafeDelete(n); + n=tempNode; } + SafeDelete(m_head); SafeDelete(m_tail); }