Home > Back-end >  Questions about C list memory release
Questions about C list memory release

Time:09-21

Recently did a topic, involves the release of the linked list node operation, so program debugging the careful observation, written for me to release all the nodes of the following functions:
Void delall (list * head)
{
If (head==NULL)
return;
The list * node=head;
While (node - & gt; next!=NULL)
{
The list * next=node - & gt; next;
Delete the node;
The node=next;
}
The head=NULL;
}

Have a question that, although each node point to release the memory, but the pointer to the node itself is still there, in addition to the first node to NULL, the other is the original address, how to solve this?

CodePudding user response:

A pointer to an int variables have distinction? Just a memory address, an integer, if is allocated on the stack, the function returns when it released,
  • Related