/*---list.c file ---*/ #include // printf() #include // malloc() #include "list.h" // NODE_T, LIST_T void NodeDisplay(NODE_T *node) { printf("%d\n",node->a); return; } void NodeCreate(LIST_T *list, int a) { NODE_T *newNode = malloc(sizeof(*newNode)); if(NULL == newNode) { fprintf(stderr, "malloc(newNode) failed.\n"); goto CLEANUP; } if(NULL == list) { fprintf(stderr, "Passing NULL as the list address not allowed.\n"); goto CLEANUP; } /* Initialize new node fields (payload) */ newNode->a = a; /* Link newNode as new 'list head' node. */ newNode->next = list->head ? list->head->next : NULL; list->head = newNode; newNode=NULL; CLEANUP: if(newNode) free(newNode); return; }