fix(codes/cpp): Memory leak fix: the space was not freed when pop removed the element. (#423)
This commit is contained in:
parent
ceeb138487
commit
3173d02538
@ -92,6 +92,7 @@ public:
|
|||||||
if (fNext != nullptr) {
|
if (fNext != nullptr) {
|
||||||
fNext->prev = nullptr;
|
fNext->prev = nullptr;
|
||||||
front->next = nullptr;
|
front->next = nullptr;
|
||||||
|
delete front;
|
||||||
}
|
}
|
||||||
front = fNext; // 更新头结点
|
front = fNext; // 更新头结点
|
||||||
// 队尾出队操作
|
// 队尾出队操作
|
||||||
@ -102,6 +103,7 @@ public:
|
|||||||
if (rPrev != nullptr) {
|
if (rPrev != nullptr) {
|
||||||
rPrev->next = nullptr;
|
rPrev->next = nullptr;
|
||||||
rear->prev = nullptr;
|
rear->prev = nullptr;
|
||||||
|
delete rear;
|
||||||
}
|
}
|
||||||
rear = rPrev; // 更新尾结点
|
rear = rPrev; // 更新尾结点
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user