-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathms_malloc.c
More file actions
63 lines (57 loc) · 1.89 KB
/
ms_malloc.c
File metadata and controls
63 lines (57 loc) · 1.89 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ms_malloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: obeedril <obeedril@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/11 21:09:54 by obeedril #+# #+# */
/* Updated: 2022/03/11 21:09:56 by obeedril ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void ms_malloc_array(char ***array, int size)
{
(*array) = (char **)malloc(sizeof(char *) * (size + 1));
if ((*array) == NULL)
{
write(2, "Mimisell: Allocation memory error\n", 35);
exit(EXIT_FAILURE);
}
}
void ms_malloc_str(char **name, int size)
{
(*name) = malloc(sizeof(char) * (size + 1));
if ((*name) == NULL)
{
write(2, "Mimisell: Allocation memory error\n", 35);
exit(EXIT_FAILURE);
}
}
void ms_malloc_arg(t_arg **arg, int size)
{
(*arg) = malloc(sizeof(t_arg) * (size + 1));
if ((*arg) == NULL)
{
write(2, "Mimisell: Allocation memory error\n", 35);
exit(EXIT_FAILURE);
}
}
void ms_malloc_cmd(t_cmd **cmd, int size)
{
(*cmd) = malloc(sizeof(t_cmd) * (size + 1));
if ((*cmd) == NULL)
{
write(2, "Mimisell: Allocation memory error\n", 35);
exit(EXIT_FAILURE);
}
}
void ms_malloc_arr_int(int **arr_int, int size)
{
(*arr_int) = (int *)malloc(sizeof(int) * (size + 1));
if ((*arr_int) == NULL)
{
write(2, "Mimisell: Allocation memory error\n", 35);
exit(EXIT_FAILURE);
}
}