aboutsummaryrefslogtreecommitdiff
path: root/src/lst/ft_lstreverse_ret.c
blob: 03ae98ed9add135b3e28b7493a1a4f98c367cffe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_lstreverse_ret.c                                :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/01/15 12:51:15 by cacharle          #+#    #+#             */
/*   Updated: 2020/01/15 13:36:46 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft.h"

t_list	*ft_lstreverse_ret(t_list *lst)
{
	t_list	*tmp;
	if (lst == NULL)
		return (NULL);
	if (lst->next == NULL)
		return (lst);
	tmp = ft_lstreverse_ret(lst->next);
	lst->next->next = lst;
	lst->next = NULL;
	return (tmp);
}