Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_find_node | ||
4 | ** File description: | ||
5 | ** Finds a node in a linked list and return it | ||
6 | */ | ||
7 | /** | ||
8 | * @file my_find_node.c | ||
9 | * @brief The file containing the my_find_node function | ||
10 | * @author Nicolas TORO | ||
11 | */ | ||
12 | |||
13 | #include "mylist.h" | ||
14 | |||
15 | 7 | node_t *my_find_node(node_t const *begin, void const *data_ref, int (*cmp) ()) | |
16 | { | ||
17 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
|
16 | for (node_t *tmp = (node_t *)begin; tmp != NULL; tmp = |
18 | tmp->next) { | ||
19 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
12 | if ((cmp == NULL && tmp->data == data_ref) |
20 |
3/4✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 9 times.
|
12 | || (cmp != NULL && cmp(tmp->data, data_ref) == 0)) |
21 | 3 | return tmp; | |
22 | } | ||
23 | 4 | return NULL; | |
24 | } | ||
25 |