From 44b77815b30d9667bc79abe0373b3b465b85c2f0 Mon Sep 17 00:00:00 2001 From: Tobias Grampp Date: Wed, 12 Nov 2025 12:23:55 +0100 Subject: [PATCH 1/2] Added CreateMatrix Function --- matrix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matrix.c b/matrix.c index 59fd963..de25a4a 100644 --- a/matrix.c +++ b/matrix.c @@ -13,7 +13,10 @@ typedef struct Matrix { Matrix createMatrix(unsigned int rows, unsigned int cols) { - + Matrix newMatrix; + newMatrix.rows = rows; + newMatrix.cols = cols; + newMatrix.buffer = calloc(rows*cols, sizeof(MatrixType)) } void clearMatrix(Matrix *matrix) From 7acece0571ee7922a23738958602c82f6f07b1c5 Mon Sep 17 00:00:00 2001 From: Tobias Grampp Date: Wed, 12 Nov 2025 12:27:15 +0100 Subject: [PATCH 2/2] Added ClearMatrix Function And Added Return Value to CreateMatrix --- matrix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matrix.c b/matrix.c index de25a4a..5dd668c 100644 --- a/matrix.c +++ b/matrix.c @@ -17,11 +17,13 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) newMatrix.rows = rows; newMatrix.cols = cols; newMatrix.buffer = calloc(rows*cols, sizeof(MatrixType)) + return newMatrix; } void clearMatrix(Matrix *matrix) { - + free(*matrix.buffer); + *matrix.buffer = NULL; } void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)