GCC Code Coverage Report


Directory: ./
File: list.c
Date: 2025-03-05 16:06:48
Exec Total Coverage
Lines: 33 33 100.0%
Functions: 6 6 100.0%
Branches: 2 2 100.0%

Line Branch Exec Source
1 #include "list.h"
2
3 void
4 171 liftoff_list_init(struct liftoff_list *list)
5 {
6 171 list->prev = list;
7 171 list->next = list;
8 171 }
9
10 void
11 453 liftoff_list_insert(struct liftoff_list *list, struct liftoff_list *elm)
12 {
13 453 elm->prev = list;
14 453 elm->next = list->next;
15 453 list->next = elm;
16 453 elm->next->prev = elm;
17 453 }
18
19 void
20 280 liftoff_list_remove(struct liftoff_list *elm)
21 {
22 280 elm->prev->next = elm->next;
23 280 elm->next->prev = elm->prev;
24 280 elm->next = NULL;
25 280 elm->prev = NULL;
26 280 }
27
28 void
29 36 liftoff_list_swap(struct liftoff_list *this, struct liftoff_list *other)
30 {
31 struct liftoff_list tmp;
32
33 36 liftoff_list_insert(other, &tmp);
34 36 liftoff_list_remove(other);
35 36 liftoff_list_insert(this, other);
36 36 liftoff_list_remove(this);
37 36 liftoff_list_insert(&tmp, this);
38 36 liftoff_list_remove(&tmp);
39 36 }
40
41 size_t
42 156 liftoff_list_length(const struct liftoff_list *list)
43 {
44 struct liftoff_list *e;
45 size_t count;
46
47 156 count = 0;
48 156 e = list->next;
49
2/2
✓ Branch 0 (4→3) taken 366 times.
✓ Branch 1 (4→5) taken 156 times.
522 while (e != list) {
50 366 e = e->next;
51 366 count++;
52 }
53
54 156 return count;
55 }
56
57 bool
58 52 liftoff_list_empty(const struct liftoff_list *list)
59 {
60 52 return list->next == list;
61 }
62