#include <stdio.h>#include <stdlib.h>#include "fatal.h"#include "list.h"ListMakeEmpty(ListL){if(L!=NULL)DeleteList(L);L=(List)malloc(sizeof(structNode));if(L==NULL)FatalError("Out of memory!");L->Next=NULL;returnL;}intIsEmpty(ListL){returnL->Next==NULL;}intIsLast(PositionP,ListL){returnP->Next==NULL;}PositionFind(ElementTypeX,ListL){PositionP;P=L->Next;while(P!=NULL&&P->Element!=X)P=P->Next;returnP;}voidDelete(ElementTypeX,ListL){PositionP,TmpCell;P=FindPrevious(X,L);if(!IsLast(P,L)){TmpCell=P->Next;P->Next=TmpCell->Next;free(TmpCell);}}PositionFindPrevious(ElementTypeX,ListL){PositionP;P=L;while(P->Next!=NULL&&P->Next->Element!=X)P=P->Next;returnP;}voidInsert(ElementTypeX,ListL,PositionP){PositionTmpCell;TmpCell=(Position)malloc(sizeof(structNode));if(TmpCell==NULL)FatalError("Out of space!!!");TmpCell->Element=X;TmpCell->Next=P->Next;P->Next=TmpCell;}voidDeleteList(ListL){PositionP,Tmp;P=L->Next;L->Next=NULL;while(P!=NULL){Tmp=P->Next;free(P);P=Tmp;}}PositionHeader(ListL){returnL;}PositionFirst(ListL){returnL->Next;}PositionAdvance(PositionP){returnP->Next;}ElementTypeRetrieve(PositionP){returnP->Element;}