-
Notifications
You must be signed in to change notification settings - Fork 0
/
mr_proper.c
91 lines (80 loc) · 1.94 KB
/
mr_proper.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mr_proper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qdegraev <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/08 18:05:03 by qdegraev #+# #+# */
/* Updated: 2016/03/11 16:20:19 by qdegraev ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "ft_ls.h"
void ft_lst_sortinsert(t_list **beg_lst, t_list *new, int o,
int (*sort)(t_dircont *, void *, int))
{
t_list *tmp;
t_list *tmp2;
tmp = NULL;
tmp2 = NULL;
tmp = *beg_lst;
while (tmp && sort(((t_dircont*)new->content), tmp->content, o) > 0)
{
tmp2 = tmp;
tmp = tmp->next;
}
if (!tmp)
tmp2->next = new;
else if (tmp == *beg_lst)
{
new->next = tmp;
*beg_lst = new;
}
else
{
tmp = tmp2;
new->next = tmp->next;
tmp->next = new;
}
}
void ft_lst_insert(t_list **lst, t_list *in)
{
t_list *tmp;
tmp = NULL;
if (!*lst)
*lst = in;
else
{
tmp = in;
while (tmp->next)
tmp = tmp->next;
tmp->next = (*lst)->next;
(*lst)->next = in;
}
tmp = *lst;
}
void del_dircont(void *to_del)
{
t_dircont *dc;
dc = to_del;
free(dc->name);
free(dc->type);
free(dc->path);
free(to_del);
}
void del_string(void *to_del)
{
char *tmp;
tmp = to_del;
ft_strdel(&tmp);
}
void lst_delone(t_list **lst, void (*del)(void *))
{
t_list *tmp;
tmp = NULL;
tmp = (*lst)->next;
del((*lst)->content);
free(*lst);
*lst = tmp;
}