X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Flist%2Flist.c;fp=lib%2Flist%2Flist.c;h=d9bc5324f25a645223a496de0292188e02da7cb1;hp=0000000000000000000000000000000000000000;hb=32e6a41f33e5576716b351bd473a27939fe94fa1;hpb=000a92b4fa909c432732ac3ed8f28eeeaeac70ee diff --git a/lib/list/list.c b/lib/list/list.c new file mode 100644 index 0000000..d9bc532 --- /dev/null +++ b/lib/list/list.c @@ -0,0 +1,24 @@ + +#include "list/list.h" + +void list_init(struct list *list) +{ + list->head.next = &list->head; + list->head.prev = &list->head; +} + +void list_add(struct list *list, struct list_item *new) +{ + new->next = list->head.next; + new->prev = &list->head; + + list->head.next->prev = new; + list->head.next = new; +} + +void list_remove(struct list_item *item) +{ + item->next->prev = item->prev; + item->prev->next = item->next; +} +