Skip to content

Commit

Permalink
fix(codes/cpp): Memory leak fix: the space was not freed when pop rem…
Browse files Browse the repository at this point in the history
…oved the element. (krahets#423)
  • Loading branch information
Gonglja authored Mar 19, 2023
1 parent ceeb138 commit 3173d02
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions codes/cpp/chapter_stack_and_queue/linkedlist_deque.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class LinkedListDeque {
if (fNext != nullptr) {
fNext->prev = nullptr;
front->next = nullptr;
delete front;
}
front = fNext; // 更新头结点
// 队尾出队操作
Expand All @@ -102,6 +103,7 @@ class LinkedListDeque {
if (rPrev != nullptr) {
rPrev->next = nullptr;
rear->prev = nullptr;
delete rear;
}
rear = rPrev; // 更新尾结点
}
Expand Down

0 comments on commit 3173d02

Please sign in to comment.