mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
Free memory after removing
a node from a LinkedList or TreeNode.
This commit is contained in:
@@ -331,7 +331,10 @@ comments: true
|
||||
int poll() {
|
||||
int num = peek();
|
||||
// 删除头结点
|
||||
ListNode *tmp = front;
|
||||
front = front->next;
|
||||
// 释放内存
|
||||
delete tmp;
|
||||
queSize--;
|
||||
return num;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user