Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_previous_to_next | ||
4 | ** File description: | ||
5 | ** The file containing the my_previous_to_next function | ||
6 | */ | ||
7 | /** | ||
8 | * @file my_previous_to_next.c | ||
9 | * @brief The file containing the my_previous_to_next function | ||
10 | * @author Gianni TUERO | ||
11 | */ | ||
12 | |||
13 | #include "mylist.h" | ||
14 | |||
15 | 8 | node_t *my_previous_to_next(node_t **head, node_t *to_delete) | |
16 | { | ||
17 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
|
8 | if (*head == NULL || to_delete == NULL) |
18 | ✗ | return NULL; | |
19 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
|
8 | if (*head == to_delete) { |
20 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (to_delete->next != NULL) { |
21 | 5 | (*head) = to_delete->next; | |
22 | } else | ||
23 | ✗ | (*head) = NULL; | |
24 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (*head != NULL) |
25 | 5 | (*head)->prev = NULL; | |
26 | 5 | return to_delete; | |
27 | } | ||
28 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (to_delete->prev != NULL) |
29 | 3 | to_delete->prev->next = to_delete->next; | |
30 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (to_delete->next != NULL) |
31 | ✗ | to_delete->next->prev = to_delete->prev; | |
32 | 3 | return to_delete; | |
33 | } | ||
34 |