-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfree.c
More file actions
79 lines (71 loc) · 1.91 KB
/
free.c
File metadata and controls
79 lines (71 loc) · 1.91 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hyeyeom <hyeyeom@42student.gyeongsan.kr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/28 09:22:57 by yuhyoon #+# #+# */
/* Updated: 2025/04/14 00:38:35 by hyeyeom ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void free_str_array(char **arr)
{
int i;
if (!arr)
return ;
i = 0;
while (arr[i])
{
free(arr[i]);
arr[i] = NULL;
i++;
}
free(arr);
}
void dengling(void *content, int size_type)
{
if (size_type == 1)
free((char *)content);
if (size_type == 4)
free((pid_t *)content);
content = NULL;
}
void free_envp_list(t_envp **head)
{
t_envp *current;
t_envp *next;
current = *head;
while (current != NULL)
{
next = current->next;
free(current->key);
free(current->value);
free(current);
current = next;
}
*head = NULL;
}
void free_all_envps(t_minish *sh)
{
free_envp_list(&(sh->n_envs));
free_envp_list(&(sh->n_export));
free_double_char(sh->envp);
}
void free_minish(t_minish *minish)
{
if (minish->mask)
free(minish->mask);
if (minish->src)
free(minish->src);
if (minish->ready)
ft_lstclear(&minish->ready, del_ready);
if (minish->child_pids)
free(minish->child_pids);
minish->prev_for_pipe = -1;
minish->mask = NULL;
minish->src = NULL;
minish->ready = NULL;
minish->child_pids = NULL;
}