-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_list.c
56 lines (50 loc) · 1.47 KB
/
init_list.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init_list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mtacnet <mtacnet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/05/26 11:58:17 by mtacnet #+# #+# */
/* Updated: 2017/06/17 17:10:26 by mtacnet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
t_elem *new_list(void)
{
return (NULL);
}
int is_empty(void *lst)
{
if (lst == NULL)
return (1);
return (0);
}
t_elem *init_element(t_elem *element)
{
element = (t_elem*)malloc(sizeof(t_elem));
if (element == NULL)
{
ft_putendl("MEMORY ALLOCATION ERROR");
exit(EXIT_FAILURE);
}
element->path = NULL;
element->name = NULL;
element->content = NULL;
element->next = NULL;
return (element);
}
void freelst(t_elem *lst)
{
t_elem *tmp;
while (lst != NULL)
{
tmp = lst;
free(tmp->path);
free(tmp->name);
free(tmp);
tmp = NULL;
lst = lst->next;
}
lst = NULL;
}