[求助]运行到条件就死机,为什么?
程序运行到条件(红字,有下划线的)就死机,有哪位大虾知道为什么?typedef struct{
int OccurTime;
int NType;
}Event,ElemType;
typedef struct LNode{
ElemType data;
struct LNode *next;
}*Link,*Position;
typedef struct{
Link head,tail;
int len;
}LinkList;
typedef LinkList EventList;
Status MakeNode(Link *p,ElemType e)
{
*p=(Link)malloc(sizeof(struct LNode));
if(!*p) return ERROR;
(*p)->data.OccurTime=e.OccurTime;
(*p)->data.NType=e.NType;
(*p)->next=NULL;
return OK;
}
Status OrderInsert(EventList *ev, ElemType a)
{
Link b,c=NULL,d=NULL;
if(!MakeNode(&d,a)) return ERROR;
for(b=ev->head;b!=NULL||a.OccurTime>=b->data.OccurTime;c=b,b=b->next);
if(b==NULL){
if(!ListLength(&ev)){
ev->tail=d;
ev->head=d;
}
else{
ev->tail.next=d;
ev->tail=d;
}
else if(c==NULL){
d->next=ev->head;
ev->head=d;
}
else {
d->next=c->next;
c->next=d;
}
ev->len++;
return OK;
}