From c3484adc5696c68a7988bcd4fc7053f5b7a9506f Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 5 May 2024 15:30:22 +0200 Subject: Added usage of reallocarray() --- FICS/multicol.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'FICS') diff --git a/FICS/multicol.c b/FICS/multicol.c index 69f33eb..60a4a32 100644 --- a/FICS/multicol.c +++ b/FICS/multicol.c @@ -26,6 +26,8 @@ #include "stdinclude.h" #include "common.h" +#include + #include "multicol.h" #include "rmalloc.h" #include "utils.h" @@ -38,7 +40,12 @@ multicol_start(int maxArray) m = rmalloc(sizeof(multicol)); m->arraySize = maxArray; m->num = 0; - m->strArray = rmalloc(sizeof(char *) * m->arraySize); + m->strArray = reallocarray(NULL, sizeof(char *), m->arraySize); + + if (m->strArray == NULL) + err(1, "%s: reallocarray", __func__); + else + malloc_count++; for (int i = 0; i < m->arraySize; i++) m->strArray[i] = NULL; -- cgit v1.2.3