Linked lists and new/delete?
Alot of the tutorials on linked lists that i have gone through lately, uses the new operator to allocate memory for a new node in the list, but never checks if the allocation failed, and they don't use the delete operator to clear the memory afterwards either, this includes the tut on cprogramming.com. Why is that? Is there a particular reason?
Also, i've tried to make a loop to destroy a linked list of mine after usage, but i keep getting segmentation errors when i run it:
Conductor is the pointer i'm using to traverse the list, temp_conductor is a similar pointer that i'm using to temporarily hold the value of conductor while i delete the node conductor points to.
while(conductor != NULL)
temp_conductor = conductor->next;
conductor = temp_conductor;
conductor = conductor->next;
My guess is that the line i've highlighted is giving me problems, rather than deleting conductor itself, i wan't to delete the node that conductor is pointing to, how would i go about this?