From e3dc5600db3dc319c7426f31f7d2d30e1b20187d Mon Sep 17 00:00:00 2001 From: Aubin DORIVAL Date: Thu, 12 Dec 2024 12:09:42 +0100 Subject: [PATCH] calloc --- function.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/function.c b/function.c index b26e16e..d2dbd70 100644 --- a/function.c +++ b/function.c @@ -8,7 +8,7 @@ unsigned short int **creatArea2D(const unsigned int N) { unsigned short int **tab2d; - tab2d = malloc(sizeof(unsigned short int* ) * N); + tab2d = calloc(N, sizeof(unsigned short int* )); if (tab2d == NULL) { return NULL; @@ -18,7 +18,7 @@ unsigned short int **creatArea2D(const unsigned int N) int i; for (i = 0; i < N && !fail; ++i) { - tab2d[i] = malloc(sizeof(unsigned short int) * N); + tab2d[i] = calloc(N, sizeof(unsigned short int)); if (tab2d[i] == NULL) { fail = true;