-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils3.c
64 lines (53 loc) · 1.47 KB
/
utils3.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smbaabu <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/12 18:29:19 by smbaabu #+# #+# */
/* Updated: 2019/04/13 17:34:31 by smbaabu ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int *create_flags(int n)
{
int *ret;
int i;
ret = (int *)malloc(n * sizeof(int));
i = 0;
while (i < n)
ret[i++] = 0;
return (ret);
}
void clear_flags(int *flags, int n)
{
int i;
i = 0;
while (i < n)
flags[i++] = 0;
}
int atleast_one(int *flags, int n)
{
int i;
i = 0;
while (i < n)
if (flags[i++] == 1)
return (1);
return (-1);
}
int **create_info(int *info[], int n)
{
int i;
i = 0;
while (i < n)
info[i++] = (int *)malloc(sizeof(int));
return (info);
}
void destroy_info(int *info[], int n)
{
int i;
i = 0;
while (i < n)
free(info[i++]);
}