mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-13 07:46:06 +00:00
Bug fixes to C code.
This commit is contained in:
@@ -49,6 +49,17 @@ ListNode *getListNode(ListNode *head, int val) {
|
||||
return head;
|
||||
}
|
||||
|
||||
/* Free the memory allocated to a linked list */
|
||||
void freeMemoryLinkedList(ListNode *cur) {
|
||||
// 释放内存
|
||||
ListNode *pre;
|
||||
while (cur != NULL) {
|
||||
pre = cur;
|
||||
cur = cur->next;
|
||||
free(pre);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user