-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuiltin_utils.c
More file actions
executable file
·67 lines (58 loc) · 1.58 KB
/
builtin_utils.c
File metadata and controls
executable file
·67 lines (58 loc) · 1.58 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* builtin_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hyeyeom <hyeyeom@42student.gyeongsan.kr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/23 20:31:38 by hyeyeom #+# #+# */
/* Updated: 2025/04/14 00:38:35 by hyeyeom ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int count_env_list(t_envp *head)
{
int count;
count = 0;
while (head)
{
count++;
head = head->next;
}
return (count);
}
int f_count_char(char **envp)
{
int count;
count = 0;
while (envp[count])
count++;
return (count);
}
void free_node_t_envp(t_envp **envp)
{
t_envp *current;
t_envp *next;
current = *envp;
while (current)
{
next = current->next;
free(current->key);
if (current->value)
free(current->value);
free(current);
current = next;
}
*envp = NULL;
}
void free_double_char(char **double_char)
{
int i;
int length;
i = -1;
length = f_count_char(double_char);
while (++i < length)
free(double_char[i]);
free(double_char);
double_char = NULL;
}