Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_rev_list | ||
4 | ** File description: | ||
5 | ** Reverses a linked list | ||
6 | */ | ||
7 | /** | ||
8 | * @file my_rev_list.c | ||
9 | * @brief The file containing the my_rev_list function | ||
10 | * @author Nicolas TORO | ||
11 | */ | ||
12 | |||
13 | #include "mylist.h" | ||
14 | |||
15 | 1 | void my_rev_list(node_t **begin) | |
16 | { | ||
17 | 1 | node_t *previous_list = NULL; | |
18 | 1 | node_t *current_list = *begin; | |
19 | 1 | node_t *next_list = NULL; | |
20 | |||
21 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | while (current_list != NULL) { |
22 | 3 | next_list = current_list->next; | |
23 | 3 | current_list->next = previous_list; | |
24 | 3 | current_list->prev = next_list; | |
25 | 3 | previous_list = current_list; | |
26 | 3 | current_list = next_list; | |
27 | } | ||
28 | 1 | *begin = previous_list; | |
29 | 1 | } | |
30 |