dte test coverage


Directory: ./
File: src/util/list.h
Date: 2025-05-08 15:05:54
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 6 6 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 #ifndef UTIL_LIST_H
2 #define UTIL_LIST_H
3
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include "macros.h"
7
8 typedef struct ListHead {
9 struct ListHead *next, *prev;
10 } ListHead;
11
12 84 static inline void list_init(ListHead *head)
13 {
14 84 head->next = head;
15 84 head->prev = head;
16 84 }
17
18 117 static inline void list_insert(ListHead *new, ListHead *prev, ListHead *next)
19 {
20 117 next->prev = new;
21 117 new->next = next;
22 117 new->prev = prev;
23 117 prev->next = new;
24 117 }
25
26 116 static inline void list_insert_before(ListHead *new, ListHead *item)
27 {
28 116 list_insert(new, item->prev, item);
29 116 }
30
31 1 static inline void list_insert_after(ListHead *new, ListHead *item)
32 {
33 1 list_insert(new, item, item->next);
34 1 }
35
36 4 static inline void list_remove(ListHead *entry)
37 {
38 4 entry->next->prev = entry->prev;
39 4 entry->prev->next = entry->next;
40 4 *entry = (ListHead){NULL, NULL};
41 4 }
42
43 524 static inline bool list_empty(const ListHead *head)
44 {
45 524 return head->next == head;
46 }
47
48 #endif
49