-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstrm_i.c
41 lines (38 loc) · 1.29 KB
/
ft_lstrm_i.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
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstrm_i.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mesafi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/11 20:04:30 by mesafi #+# #+# */
/* Updated: 2020/01/20 13:29:31 by mesafi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
void ft_lstrm_i(t_list **head, int i)
{
t_list *next;
t_list *tmp;
if (head == NULL || *head == NULL)
return ;
if (i == 0)
{
ft_lstrm(head);
return ;
}
tmp = *head;
if (i == ft_lstcount(tmp) - 1)
{
ft_lstpop(tmp);
return ;
}
if (i >= ft_lstcount(tmp))
return ;
while (--i > 0)
tmp = tmp->next;
next = tmp->next->next;
free(tmp->next);
tmp->next = next;
}