From 17205366673063571351d8e7a35940af225bcd0c Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 6 Nov 2026 22:46:39 +0100 Subject: [PATCH] createM FailsOnZeroDim, beheben --- Startcode/matrix.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Startcode/matrix.c b/Startcode/matrix.c index a312941..cf04771 100644 --- a/Startcode/matrix.c +++ b/Startcode/matrix.c @@ -9,6 +9,13 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) Matrix m; m.rows = rows; m.cols = cols; + + if(rows == 0|| cols == 0) // Zeile oder Spalte = 0, dann keine Speicher anfordern, sonder Buffer auf NULL setzen + { + m.buffer = NULL; + return m; + } + m.buffer = (MatrixType*) calloc(rows * cols, sizeof(MatrixType)); // calloc, statt malloc benutzt, um direkt alle Werte mit 0 zu initialisieren return m; }