//linkedListLib1.c //John T. Rine //October 6, 2011 //lab46:~$ gcc -c linkedListLib.c -o linkedListLib.o //lab46:~$ ar crs liblinkedListLib.a linkedListLib.o //lab46:~$ gcc -I. linkedListTest.c -o linkedListTest liblinkedListLib.a #include #include //#include"linkedListLib1.h" #include"linkedListLib.h" void createList(node **headd, node **taill, int elements) { int i; node *new, *head, *tail; new = head = tail = NULL; for(i = 1; i<=elements; i++) { if (head == NULL) { head = (node *) malloc(sizeof(node)); tail = head; head->prev = NULL; head->next = NULL; } else { new = (node *) malloc(sizeof(node)); new->prev = tail; new->next = NULL; tail->next = new; tail = new; } } *headd = head; *taill = tail; } void destroyListHead(node *head) { node *temp; node *temp2; temp = NULL; temp2 = NULL; temp = head; while(temp != NULL) { temp2 = temp->next; if (temp->prev != NULL) temp->prev = NULL; if (temp->next != NULL) temp->next = NULL; free(temp); temp = temp2; } } void destroyListTail(node *tail) { node *temp; node *temp2; temp = NULL; temp2 = NULL; temp = tail; while(temp != NULL) { temp2 = temp->prev; if (temp->prev != NULL) temp->prev = NULL; if (temp->next != NULL) temp->next = NULL; free(temp); temp = temp2; } } int listSizeHead(node *head) { int size = 0; while (head != NULL) { head = head->next; size++; } return size; }