提交 f1f9c656 编写于 作者: @大熊_'s avatar @大熊_

添加Destroy功能

上级 ea9cfff7
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Description: 单链表 * @Description: 单链表
* @Author: 大熊人 * @Author: 大熊人
* @Date: 2020-10-30 20:17:20 * @Date: 2020-10-30 20:17:20
* @LastEditTime: 2020-11-01 22:33:40 * @LastEditTime: 2020-11-08 00:09:04
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -172,6 +172,21 @@ int ListLength(LinkList L) ...@@ -172,6 +172,21 @@ int ListLength(LinkList L)
return count; return count;
} }
/**
* @description: 销毁单链表
* @param {struct **}L
*/
void Destroy(LinkList *L)
{
if (*L == NULL)
{
return;
}
Destroy(&(*L)->Next);
free(*L);
*L = NULL;
}
/** /**
* @description: 测试单链表 * @description: 测试单链表
*/ */
...@@ -199,4 +214,10 @@ void TestLinkList() ...@@ -199,4 +214,10 @@ void TestLinkList()
PrintLinkList(head); PrintLinkList(head);
printf("\nListLength=%d\n", ListLength(head)); printf("\nListLength=%d\n", ListLength(head));
Destroy(&head);
}
void main()
{
TestLinkList();
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册