summaryrefslogtreecommitdiffstats
path: root/lib/list/list.c
blob: b781bc65ac4fb5d04e11979f8a4dfe10cb25690e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#include "list/list.h"

void list_init(struct list *list)
{
	list->head.next = &list->head;
	list->head.prev = &list->head;
}

void list_insert_before(struct list_item *next, struct list_item *new)
{
	new->next = next;
	new->prev = next->prev;
	next->prev->next = new;
	next->prev = new;
}

void list_insert_after(struct list_item *prev, struct list_item *new)
{
	new->next = prev->next;
	new->prev = prev;
	prev->next->prev = new;
	prev->next = new;
}

void list_remove(struct list_item *item)
{
	item->next->prev = item->prev;
	item->prev->next = item->next;
}
OpenPOWER on IntegriCloud