-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstins.c
executable file
·34 lines (31 loc) · 1.25 KB
/
ft_lstins.c
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
32
33
34
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_lstins.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: brobicho <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/07/25 15:55:10 by brobicho #+# ## ## #+# */
/* Updated: 2018/07/25 15:55:14 by brobicho ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
void ft_lstins(t_list **lst, t_list *new, size_t index)
{
t_list *insert;
t_list *tmp;
if (index == 0)
{
tmp = *lst;
*lst = new;
(*lst)->next = tmp;
}
else
{
insert = ft_lstat(*lst, index - 1);
tmp = insert->next;
insert->next = new;
insert->next->next = tmp;
}
}