LinkedList: Make sure to explicitly mark the first node's next and last nodes as nullptr
This commit is contained in:
parent
07e6ebd3cc
commit
146da13e43
@ -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++;
|
||||||
|
Loading…
Reference in New Issue
Block a user