From f592c3cedee61e8449f9aa9aeb5122d8370588f9 Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Tue, 16 Apr 2019 16:09:09 +0200 Subject: [PATCH] met le dernier element du char** a null dans add_to_list et parse --- add_to_list.c | 3 ++- parse_input.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/add_to_list.c b/add_to_list.c index 0eb22ac..29af60e 100644 --- a/add_to_list.c +++ b/add_to_list.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ -/* Updated: 2019/04/16 15:32:14 by hulamy ### ########.fr */ +/* Updated: 2019/04/16 16:08:24 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,6 +31,7 @@ char **fill_tetraminos(char **square, int *tab) length = tab[3] - tab[1] + 1; if (!(result = (char**)malloc(sizeof(*result) * (height + 1)))) return (NULL); + result[height] = NULL; while (i < height) { if (!(result[i] = (char*)malloc(sizeof(**result) * (length + 1)))) diff --git a/parse_input.c b/parse_input.c index 122a202..253735d 100644 --- a/parse_input.c +++ b/parse_input.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ -/* Updated: 2019/04/16 15:28:11 by hulamy ### ########.fr */ +/* Updated: 2019/04/16 16:08:03 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,8 +23,9 @@ char **create_square(char *tetri) int k; i = 0; - if (!(square = (char**)malloc(sizeof(*square) * 4))) + if (!(square = (char**)malloc(sizeof(*square) * (4 + 1)))) return (NULL); + square[4] = NULL; while (*tetri && (k = -1)) { if (!(square[i] = (char*)malloc(sizeof(**square) * (4 + 1))))