From f0bc0ce06a6a60da35969a7707107d58201f65e5 Mon Sep 17 00:00:00 2001 From: Niklas Wolf Date: Mon, 10 Nov 2025 15:13:32 +0100 Subject: [PATCH 1/2] create matrix func wip --- matrix.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/matrix.c b/matrix.c index ad00628..b6dcaca 100644 --- a/matrix.c +++ b/matrix.c @@ -6,7 +6,25 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) { - + Matrix m; + m.rows = rows; + m.cols = cols; + m.data = NULL; + + if(rows == 0 || cols == 0) + { + return m; + } + + m.data = calloc(rows * cols, sizeof(MatrixType)); + if (m.data == NULL) + { + m.rows = 0; + m.cols = 0; + return m; + } + + return m; } void clearMatrix(Matrix *matrix) From 3a7279468498df35fd8045ed334ded8800310814 Mon Sep 17 00:00:00 2001 From: Niklas Wolf Date: Mon, 10 Nov 2025 15:33:39 +0100 Subject: [PATCH 2/2] create matrix update wip --- matrix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/matrix.c b/matrix.c index b6dcaca..e430469 100644 --- a/matrix.c +++ b/matrix.c @@ -13,15 +13,15 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) if(rows == 0 || cols == 0) { - return m; + printf("Error"); + exit(EXIT_FAILURE); } m.data = calloc(rows * cols, sizeof(MatrixType)); if (m.data == NULL) { - m.rows = 0; - m.cols = 0; - return m; + printf("Error"); + exit(EXIT_FAILURE); } return m;