5 /* allocates and initialises list structure; returns NULL if malloc fails */
6 struct list *list_create() {
7 struct list *list = malloc(sizeof(struct list));
9 memset(list, 0, sizeof(struct list));
13 /* frees all memory associated with the list */
14 void list_destroy(struct list *list) {
15 struct list_node *node, *next;
17 for (node = list->first; node; node = next) {
25 /* appends entry to list; returns 1 if ok, 0 if malloc fails */
26 int list_add(struct list *list, void *data) {
27 struct list_node *node;
29 node = malloc(sizeof(struct list_node));
37 list->last->next = node;
45 /* returns first node */
46 struct list_node *list_first(struct list *list) {
50 /* returns the next node after the argument */
51 struct list_node *list_next(struct list_node *node) {