> psList->iNodeCount+1;
What is the meaning of this?
> psNode->Prev = psNext-Prev;
Don't do this with pointers. Or did you mean
psNode->Prev = psNext->Prev;
In that case, psNext->Prev does not point to anything. You should first initialize the psNext node.
Only if
psNode->Zip > psList->psHead->Next->Zip
you add the node, but you don't do that if
psNode->Zip =< psList->psHead->Next->Zip.
Your algorithm looks not complete to me. What you could do, in a kind of pseudo:
Code:
/* Add a note to a list */
new_node = initialise_new_node()
/* Check if node must be put after the tail */
if (new_node->element > list_tail->element)
add_element_after_tail (list_tail, new_node);
return;
/* Check if node must be put before the head */
if (new_node->element < list_head->element)
add_element_before_head (list_head, new_node);
return;
/* Else the new node must be inserted in the list, search for the
first element which is larger than the element of new node. The
new node must be inserted before that element. */
list_ptr = find_first_larger_element_position (list, new_node);
insert_new_node (list_ptr, new_node);