-
So how about you start checking your values before you start trying to use them?
Code:
void insertBeforeFirst(ListRef L, int data){
NodeRef temp= newNode(data);
if(L== NULL){
printf("Queue Error: called insertBeforeFirst() on NULL ListRef\n");
exit(1);
}
if(isEmpty(L)){ L->head= L->tail= temp; }
else{
temp->next = L->head;
L->head->prev= temp;
L->head= temp;
}
L->length++;
}
Check to see that ->head exits before you start trying to access its members. Never assume a pointer points somewhere valid. It's obvious it doesn't, since your debugger is telling you it doesn't.
Quzah.
-
If this is a legitimate debugging session, then this would appear to be the first time you've inserted anything in the list -- yet the isEmpty test comes out false. Is this actually the first thing you are inserting in the list?