dte test coverage


Directory: ./
File: src/util/list.h
Date: 2025-02-14 16:55:22
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 83 static inline void list_init(ListHead *head)
13 {
14 83 head->next = head;
15 83 head->prev = head;
16 83 }
17
18 116 static inline void list_insert(ListHead *new, ListHead *prev, ListHead *next)
19 {
20 116 next->prev = new;
21 116 new->next = next;
22 116 new->prev = prev;
23 116 prev->next = new;
24 116 }
25
26 115 static inline void list_insert_before(ListHead *new, ListHead *item)
27 {
28 115 list_insert(new, item->prev, item);
29 115 }
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 523 static inline bool list_empty(const ListHead *head)
44 {
45 523 return head->next == head;
46 }
47
48 #endif
49