aboutsummaryrefslogtreecommitdiff
path: root/c12/ex04/ft_list_push_back.c
blob: b4c486b509d794a691cf273c31373bacfcd1d181 (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
27
28
29
30
31
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_list_push_back.c                                :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <charles.cabergs@gmail.com>       +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2019/07/09 17:18:46 by cacharle          #+#    #+#             */
/*   Updated: 2019/07/23 15:42:15 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <stdlib.h>
#include "ft_list.h"

void	ft_list_push_back(t_list **begin_list, void *data)
{
	t_list	*new_rear;
	t_list	*cursor;

	new_rear = ft_create_elem(data);
	if (*begin_list == NULL)
	{
		*begin_list = new_rear;
		return ;
	}
	cursor = *begin_list;
	while (cursor->next)
		cursor = cursor->next;
	cursor->next = new_rear;
}