Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2023 |
3 |
|
|
** my_rev_list |
4 |
|
|
** File description: |
5 |
|
|
** Reverses a linked list |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "mylist.h" |
9 |
|
|
|
10 |
|
✗ |
void my_rev_list(linked_list_t **begin) |
11 |
|
|
{ |
12 |
|
✗ |
linked_list_t *previous_list = NULL; |
13 |
|
✗ |
linked_list_t *current_list = *begin; |
14 |
|
✗ |
linked_list_t *next_list = NULL; |
15 |
|
|
|
16 |
|
✗ |
while (current_list != NULL) { |
17 |
|
✗ |
next_list = current_list->next; |
18 |
|
✗ |
current_list->next = previous_list; |
19 |
|
✗ |
current_list->prev = next_list; |
20 |
|
✗ |
previous_list = current_list; |
21 |
|
✗ |
current_list = next_list; |
22 |
|
|
} |
23 |
|
✗ |
*begin = previous_list; |
24 |
|
✗ |
} |
25 |
|
|
|