Linked lists:
Linked lists
suggest changeThe C language does not define a linked list data structure. If you are using C and need a linked list, you either need to use a linked list from an existing library (such as GLib) or write your own linked list interface. This topic shows examples for linked lists and double linked lists that can be used as a starting point for writing your own linked lists.
Singly linked list
The list contains nodes which are composed of one link called next.
Data structure
struct singly_node
{
struct singly_node * next;
};
Doubly linked list
The list contains nodes which are composed of two links called previous and next. The links are normally referencing to a node with the same structure.
Data structure
struct doubly_node
{
struct doubly_node * prev;
struct doubly_node * next;
};
void doubly_node_make_empty_linear_list (struct doubly_node * head, struct doubly_node * tail)
{
head->prev = NULL;
tail->next = NULL;
doubly_node_bind (head, tail);
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents
4
Arrays
11
Assertion
12
Linked lists
14
X-macros
16
Pointers
17
Structs
21
Compilation
23
Bit-fields
24
Strings
29
Valgrind
30
Typedef
34
Boolean
37
Declarations
46
Atomics
48
Enumerations
54
Side effects
56
Constrains
57
Inlining
58
Unions
62
Comments
63
Contributors