Edward Capriolo International Urges you to...
Did you know that of all the data structures in the world nodes are 9 times as likely to be orphaned when compared to a stack? It is a sad but true fact. Some blame it on the programmers who carelessly reassign pointers. While others say that is the fault of pointer template classes that confuse nodes. However many believe that since nodes are unsure of their true identity. Of course they have data, if they are a template who knows what kind of data. Its not even their own data! They are just a poor container class for someone else data. The multiple links they contain can lead a node down the wrong path as well. Imagine how the poor node feels, its pointing forward and backwards. People call it two different ways head_ptr.forwardlink() and forwardlink ->.
And of course they are confused, after all they have no true identity. No one calls a node MyNode or YourNode, they are referred to as just another node in a linked list. What a cold world. At least if you are part of an array you can say you belong to something. But the poor node if it loses one of its friends its gone to.
Well for man nodes its unfortunately too late. All you can do is protect the nodes that are not yet allocated. Here is a small checklist:
add an iterater to keep track of each individual node in the list
Do not delete a pointer unless you are trying to remove a node from the list
Try using alternative data structures whenever possible
If you have to use a linked list Make it doubly linked, incase of an accident you may be able to call on the tail pointer and recover the list.
Consider including a mid_pointer, this is kind of like a god father of linked list. In a worse case scenario you may be able to save half your list.