diff --git a/Startcode/matrix.c b/Startcode/matrix.c index cf04771..03e5b3e 100644 --- a/Startcode/matrix.c +++ b/Startcode/matrix.c @@ -7,15 +7,17 @@ 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.rows = 0; + m.cols = 0; m.buffer = NULL; return m; } - + m.rows = rows; + m.cols = cols; m.buffer = (MatrixType*) calloc(rows * cols, sizeof(MatrixType)); // calloc, statt malloc benutzt, um direkt alle Werte mit 0 zu initialisieren return m; }