| 111 | } |
| 112 | |
| 113 | void DoublyLinkedListRemoveNode(DoublyLinkedList *const list, |
| 114 | DoublyLinkedListNode **pointer_to_node_pointer) |
| 115 | { |
| 116 | DoublyLinkedListNode *node = *pointer_to_node_pointer; |
| 117 | DoublyLinkedListNode *previous = node->previous; |
| 118 | DoublyLinkedListNode *next = node->next; |
| 119 | |
| 120 | if (node == list->first && node == list->last) { |
| 121 | list->first = NULL; |
| 122 | list->last = NULL; |
| 123 | } else { |
| 124 | if(node == list->first) { |
| 125 | list->first = next; |
| 126 | } |
| 127 | if(node == list->last) { |
| 128 | list->last = previous; |
| 129 | } |
| 130 | if(NULL != previous) { |
| 131 | previous->next = next; |
| 132 | } |
| 133 | if(NULL != next) { |
| 134 | next->previous = previous; |
| 135 | } |
| 136 | |
| 137 | } |
| 138 | |
| 139 | |
| 140 | DoublyLinkedListNodeDestroy(list, pointer_to_node_pointer); |
| 141 | } |