LinkedList: Make sure to explicitly mark the first node's next and last nodes as nullptr

This commit is contained in:
apio 2022-12-06 18:23:19 +01:00
parent 07e6ebd3cc
commit 146da13e43
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -40,6 +40,8 @@ template <typename T> class DoublyLinkedList
DoublyLinkedListNode<T>* node = (DoublyLinkedListNode<T>*)ptr; DoublyLinkedListNode<T>* node = (DoublyLinkedListNode<T>*)ptr;
if (!m_start_node) m_start_node = node; if (!m_start_node) m_start_node = node;
if (m_end_node) node->add_to_list(m_end_node); if (m_end_node) node->add_to_list(m_end_node);
else
node->m_next_node = node->m_last_node = nullptr;
m_end_node = node; m_end_node = node;
m_count++; m_count++;