-
Notifications
You must be signed in to change notification settings - Fork 0
/
free_and_error.c
57 lines (49 loc) · 1.48 KB
/
free_and_error.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free_and_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbin-nas <mbin-nas@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/11 11:18:10 by mbin-nas #+# #+# */
/* Updated: 2023/01/02 16:35:45 by mbin-nas ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
// ?---------------- FREE EVERYTHING AND THE PARENTS
void free_parent(t_pipex *pipex)
{
int i;
i = 0;
close(pipex->infile);
close(pipex->outfile);
while (pipex->cmd_path[i])
{
free(pipex->cmd_path[i]);
i++;
}
free(pipex->cmd_path);
}
void free_childs(t_pipex *pipex)
{
int i;
i = 0;
while (pipex->cmd_arg[i])
{
free(pipex->cmd_arg[i]);
i++;
}
free(pipex->cmd_arg);
free(pipex->cmd);
}
// ! ---------- ERRORS MESSAGE
int message_error(char *error)
{
write(2, error, ft_strlen(error));
return (1);
}
void perror_message(char *err)
{
perror(err);
exit(EXIT_FAILURE);
}