Free memory after removing

a node from a LinkedList or TreeNode.
This commit is contained in:
Yudong Jin
2023-01-02 19:53:55 +08:00
parent 6b02449f22
commit 410c5d6b62
20 changed files with 69 additions and 140 deletions

View File

@@ -331,7 +331,10 @@ comments: true
int poll() {
int num = peek();
// 删除头结点
ListNode *tmp = front;
front = front->next;
// 释放内存
delete tmp;
queSize--;
return num;
}