-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstclone.c
39 lines (34 loc) · 1.29 KB
/
ft_lstclone.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lgasc <lgasc@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/20 15:51:22 by lgasc #+# #+# */
/* Updated: 2024/02/28 16:31:50 by lgasc ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
#include "bonus.h"
#ifdef TEST
# include "libft.h"
#endif
__attribute__ ((warn_unused_result))
t_ilist ft_ilstclone(t_ilist list)
{
t_inode *node;
t_ilist clone;
t_inode *copy;
node = list;
clone = NULL;
while (node != NULL)
{
copy = ft_ilstnew(node->datum);
if (copy == NULL)
return (ft_ilstclear(&clone), NULL);
ft_ilstadd_back(&clone, copy);
node = node->next;
}
return (clone);
}