diff --git a/codes/c/chapter_stack_and_queue/linkedlist_queue.c b/codes/c/chapter_stack_and_queue/linkedlist_queue.c index 9ffdf3b49..60437c2cf 100644 --- a/codes/c/chapter_stack_and_queue/linkedlist_queue.c +++ b/codes/c/chapter_stack_and_queue/linkedlist_queue.c @@ -24,7 +24,7 @@ LinkedListQueue *newLinkedListQueue() { /* 析构函数 */ void delLinkedListQueue(LinkedListQueue *queue) { // 释放所有节点 - for (int i = 0; i < queue->queSize && queue->front != NULL; i++) { + while (queue->front != NULL) { ListNode *tmp = queue->front; queue->front = queue->front->next; free(tmp);