#include "list.h" void list_append(struct list *list, struct list_node *node) { struct list_node *new_stl; if (list == NULL || node == NULL) { return; } new_stl = list->last; list->last = node; node->next = NULL; node->prev = new_stl; if (new_stl == NULL) { list->first = node; } else { new_stl->next = node; } } void list_prepend(struct list *list, struct list_node *node) { struct list_node *new_second; if (list == NULL || node == NULL) { return; } new_second = list->first; list->first = node; node->prev = NULL; node->next = new_second; if (new_second == NULL) { list->last = node; } else { new_second->prev = node; } }