Start of a structure.

This commit is contained in:
Ian Gulliver
2016-03-04 13:37:23 -08:00
parent 4435c6a634
commit e0462a61fe
4 changed files with 271 additions and 10 deletions

24
list.c Normal file
View File

@@ -0,0 +1,24 @@
#include <stdlib.h>
#include "list.h"
void list_head_init(struct list_head *head) {
head->next = head->prev = head;
}
bool list_is_empty(const struct list_head *head) {
return head->next == head;
}
void list_add(struct list_head *new, struct list_head *head) {
new->next = head;
new->prev = head->prev;
new->prev->next = new;
head->prev = new;
}
void list_del(struct list_head *entry) {
entry->next->prev = entry->prev;
entry->prev->next = entry->next;
entry->prev = entry->next = NULL;
}