From 68bac851e24f8a2995607e157c8ff5711852082f Mon Sep 17 00:00:00 2001 From: Manzovince Date: Sat, 1 Jun 2019 14:03:37 +0200 Subject: [PATCH 1/4] free(map) in print_binary_map - Auto stash before rebase of "origin/master" --- f_bonus_print.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/f_bonus_print.c b/f_bonus_print.c index 5076c6b..a6034c8 100644 --- a/f_bonus_print.c +++ b/f_bonus_print.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* f_bonus_print.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: hulamy +#+ +:+ +#+ */ +/* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/27 13:46:29 by hulamy #+# #+# */ -/* Updated: 2019/05/28 09:57:40 by hulamy ### ########.fr */ +/* Updated: 2019/06/01 14:00:58 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -59,6 +59,7 @@ int print_binary_map(unsigned int *map, int size, int *dope) print_sized_map(map, size, size, '#'); ft_putchar('\n'); } + free(map); return (size); } From 482861a3c9b36fe24c17fbf6ce7c8b684806c293 Mon Sep 17 00:00:00 2001 From: Manzovince Date: Sat, 1 Jun 2019 14:54:12 +0200 Subject: [PATCH 2/4] Auto stash before merge of "master" and "origin/ralentit" --- f_bonus_print.c | 1 - f_print.c | 11 ++++++----- main.c | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/f_bonus_print.c b/f_bonus_print.c index 56b9512..f58ee9e 100644 --- a/f_bonus_print.c +++ b/f_bonus_print.c @@ -59,7 +59,6 @@ int print_binary_map(unsigned int *map, int size, int *dope) print_sized_map(map, size, size, '#'); ft_putchar('\n'); } - free(map); return (size); } diff --git a/f_print.c b/f_print.c index d5ab0d2..01c14ee 100644 --- a/f_print.c +++ b/f_print.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* print.c :+: :+: :+: */ +/* f_print.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ @@ -13,8 +13,8 @@ #include "fillit.h" /* -** function that print a map of height and width -** usefull to print tetris +** Function that print a map of height and width +** useful to print tetris */ void print_sized_map(unsigned int *tab, int width, int height, char letter) @@ -44,7 +44,7 @@ void print_sized_map(unsigned int *tab, int width, int height, char letter) /* ** Print the final map with the letters ** if flag value is 0 -> print moulinette version -** if flag value is 0 -> print in color +** if flag value is p -> print in color */ char *init_print_map(t_fillist *list, int size) @@ -53,7 +53,8 @@ char *init_print_map(t_fillist *list, int size) int i; int j; - map = (char *)malloc(sizeof(*map) * (size * size + 1)); + if (!(map = (char *)malloc(sizeof(*map) * (size * size + 1)))) + return (NULL); map[size * size] = '\0'; i = -1; while (++i < size * size) diff --git a/main.c b/main.c index 3161953..781876c 100644 --- a/main.c +++ b/main.c @@ -30,7 +30,7 @@ int *create_dope(char *av, int mdp) comp = "dope"; if (!(dope = (int*)malloc(sizeof(*dope) * 4))) - return (NULL); + return (0); i = 0; while (i < 4) dope[i++] = 0; @@ -110,5 +110,6 @@ int main(int ac, char **av) else print_error("usage: Please submit a file.\n> ./fillit file.fillit\n"); free(dope); + while (1) ; return (0); } From fd696fc499b13024e280481e82c66c9a47e86457 Mon Sep 17 00:00:00 2001 From: Manzovince Date: Sat, 1 Jun 2019 15:27:46 +0200 Subject: [PATCH 3/4] oubli dans le main.c --- main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.c b/main.c index 781876c..c2903a1 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/06/01 14:40:58 by hulamy ### ########.fr */ +/* Updated: 2019/06/01 15:27:22 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -110,6 +110,5 @@ int main(int ac, char **av) else print_error("usage: Please submit a file.\n> ./fillit file.fillit\n"); free(dope); - while (1) ; return (0); } From c007a8299a262e0d2a0ffd544a0d4c35e1ae177a Mon Sep 17 00:00:00 2001 From: Manzovince Date: Sat, 1 Jun 2019 15:53:43 +0200 Subject: [PATCH 4/4] handle error correct --- f_handle_errors.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/f_handle_errors.c b/f_handle_errors.c index 93241fc..9e31ca8 100644 --- a/f_handle_errors.c +++ b/f_handle_errors.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */ -/* Updated: 2019/06/01 14:49:01 by hulamy ### ########.fr */ +/* Updated: 2019/06/01 15:53:31 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -75,6 +75,8 @@ void check_file_errors(char *file, int *dope) print_error_extended(3, dope); i++; } + if (file[i - 1] == '\n') + print_error_extended(3, dope); if (line_nbr < 4) print_error_extended(4, dope); if (!dope[3] && line_nbr > 129)