aboutsummaryrefslogtreecommitdiff
path: root/c12/ex08/ft_list_reverse.c
diff options
context:
space:
mode:
Diffstat (limited to 'c12/ex08/ft_list_reverse.c')
-rw-r--r--c12/ex08/ft_list_reverse.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/c12/ex08/ft_list_reverse.c b/c12/ex08/ft_list_reverse.c
index 23d4339..e5c2057 100644
--- a/c12/ex08/ft_list_reverse.c
+++ b/c12/ex08/ft_list_reverse.c
@@ -6,22 +6,24 @@
/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/09 18:05:23 by cacharle #+# #+# */
-/* Updated: 2019/07/17 19:13:19 by cacharle ### ########.fr */
+/* Updated: 2019/07/19 08:18:13 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
void ft_list_reverse(t_list **begin_list)
{
- t_list *tmp;
+ t_list *cursor;
t_list *prev;
+ t_list *tmp_next;
prev = NULL;
- tmp = (*begin_list)->next;
- while (tmp != NULL)
+ cursor = *begin_list;
+ while (cursor != NULL)
{
- (*begin_list)->next = prev;
- prev = *begin_list;
- *begin_list = tmp;
- tmp = (*begin_list)->next;
+ tmp_next = cursor->next;
+ cursor->next = prev;
+ prev = cursor;
+ cursor = tmp_next;
}
+ *begin_list = prev;
}