-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_validity_check_fresh.c
58 lines (53 loc) · 1.58 KB
/
ft_validity_check_fresh.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_validity_check_fresh.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: frahaing <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/21 18:50:43 by frahaing #+# #+# */
/* Updated: 2017/11/22 18:41:16 by rkrief ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
static char **ft_validity_check_norm(char **tetris, int count, int i,
char **clone)
{
int x;
int j;
x = 0;
j = 0;
while (tetris[i][j++])
if (tetris[i][j] != 'x')
count++;
clone[i] = (char *)malloc(sizeof(char) * count + 1);
j = 0;
while (tetris[i][j])
{
if (tetris[i][j] != 'x')
clone[i][x++] = tetris[i][j++];
else
j++;
}
return (clone);
}
char **ft_validity_check_fresh(char **tetris)
{
char **clone;
int count;
int i;
clone = NULL;
i = 0;
while (tetris[i])
i++;
clone = (char **)malloc(sizeof(char *) * (i + 1));
i = 0;
while (tetris[i])
{
count = 0;
clone = ft_validity_check_norm(tetris, count, i, clone);
i++;
}
clone[i] = NULL;
return (clone);
}