C language to clear two-way non-circular linked list (no leading node)
In my previous blog "basic operations for implementing a single-chain table in C Language", I implemented how to clear a single-chain table. Now I have switched to a two-way non-circular linked list. The overall idea is the same. Code upload to: https://github.com/chenyufeng1991/ClearDoubleLinkedList.
The core code is as follows:
Node * ClearDoubleLinkedList (Node * pNode) {if (pNode = NULL) {printf ("% s function execution, the original linked list is an empty linked list, no need to execute this Method \ n ", __function _); return NULL;} else {while (pNode-> next! = NULL) {// Delete each node pNode = pNode-> next; free (pNode-> prior); pNode-> prior = NULL ;} // clear the last node free (pNode); pNode = NULL; printf ("% s FUNCTION execution, two-way non-circular linked list cleared successfully \ n" ,__ FUNCTION __); return pNode ;}}