Skip to content

Commit

Permalink
Fix destructor of LinkedList_prime (close #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxylxy123456 committed Nov 29, 2020
1 parent 1860b0b commit 72c57dd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/LinkedList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ class LinkedList_prime: public LinkedListBase<T> {
nil->next->next->prev = nil->next;
}
virtual ~LinkedList_prime() {
for (Element<T>* i = nil; i != nil; ) {
for (Element<T>* i = nil->next; i != nil; ) {
Element<T>* tmp = i;
i = i->next;
delete tmp;
}
delete nil;
}
private:
Element<T>* nil;
Expand Down

0 comments on commit 72c57dd

Please sign in to comment.