libdom
Loading...
Searching...
No Matches
list.h
Go to the documentation of this file.
1/*
2 * This file is part of libdom.
3 * Licensed under the MIT License,
4 * http://www.opensource.org/licenses/mit-license.php
5 * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
6 *
7 * This file contains the list structure used to compose lists.
8 *
9 * Note: This is a implementation of a doubld-linked cyclar list.
10 */
11
12#ifndef dom_utils_list_h_
13#define dom_utils_list_h_
14
15#include <stddef.h>
16
17struct list_entry {
20};
21
27static inline void list_init(struct list_entry *ent)
28{
29 ent->prev = ent;
30 ent->next = ent;
31}
32
39static inline void list_append(struct list_entry *head, struct list_entry *new)
40{
41 new->next = head;
42 new->prev = head->prev;
43 head->prev->next = new;
44 head->prev = new;
45}
46
52static inline void list_del(struct list_entry *ent)
53{
54 ent->prev->next = ent->next;
55 ent->next->prev = ent->prev;
56
57 ent->prev = ent;
58 ent->next = ent;
59}
60
61#endif
Definition list.h:17
struct list_entry * next
Definition list.h:19
struct list_entry * prev
Definition list.h:18