diff --git a/a.out b/a.out index a55f7c0..7345a48 100755 Binary files a/a.out and b/a.out differ diff --git a/a.out.dSYM/Contents/Resources/DWARF/a.out b/a.out.dSYM/Contents/Resources/DWARF/a.out index d7eab35..5c9f559 100644 Binary files a/a.out.dSYM/Contents/Resources/DWARF/a.out and b/a.out.dSYM/Contents/Resources/DWARF/a.out differ diff --git a/add_to_list.c b/add_to_list.c index a67fe6b..936492b 100644 --- a/add_to_list.c +++ b/add_to_list.c @@ -6,14 +6,14 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ -/* Updated: 2019/04/15 16:14:46 by hulamy ### ########.fr */ +/* Updated: 2019/04/15 17:07:34 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" #include -char **fill_tetraminos(char **square, int x1, int y1, int x2, int y2) +char **fill_tetraminos(char **square, int *tab) { char **result; int height; @@ -22,11 +22,11 @@ char **fill_tetraminos(char **square, int x1, int y1, int x2, int y2) int j; i = 0; - height = x2 - x1 + 1; - length = y2 - y1 + 1; - if (!(result = (char**)malloc(sizeof(*result) * (height + 1)))) + height = tab[2] - tab[0] + 1; + length = tab[3] - tab[1] + 1; + if (!(result = (char**)malloc(sizeof(*result) * (height)))) return (NULL); - while (i < 4) + while (i < height) { if (!(result[i] = (char*)malloc(sizeof(**result) * (length + 1)))) return (NULL); @@ -36,7 +36,7 @@ char **fill_tetraminos(char **square, int x1, int y1, int x2, int y2) i = -1; while (++i < height && (j = -1)) while (++j < length) - result[i][j] = square[x1 + i][y1 + j]; + result[i][j] = square[tab[0] + i][tab[1] + j]; return (result); } @@ -69,21 +69,13 @@ void find_start_and_end(char **square, int **x) int fill_list(char **square, t_fillist *list) { int *tab; - int x1; - int x2; - int y1; - int y2; tab = (int*)malloc(sizeof(int) * 4); find_start_and_end(square, &tab); - x1 = tab[0]; - y1 = tab[1]; - x2 = tab[2]; - y2 = tab[3]; - list->size[0] = y2 - y1 + 1; - list->size[1] = x2 - x1 + 1; + list->size[0] = tab[3] - tab[1] + 1; + list->size[1] = tab[2] - tab[0] + 1; list->area = list->size[0] * list->size[1]; - list->tetraminos = fill_tetraminos(square, x1, y1, x2, y2); + list->tetraminos = fill_tetraminos(square, tab); return (1); }