diff --git a/matrix.c b/matrix.c index 4ed32c9..8fec4b7 100644 --- a/matrix.c +++ b/matrix.c @@ -1,4 +1,5 @@ #include +#include #include #include "matrix.h" @@ -6,11 +7,20 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) { - Matrix matrix; - matrix.rows = rows; - matrix.cols = cols; - matrix.buffer = (float*) calloc(rows * cols, sizeof(float)); - return matrix; + if (rows != 0 && cols != 0){ + Matrix matrix; + matrix.rows = rows; + matrix.cols = cols; + matrix.buffer = (float*) calloc(rows * cols, sizeof(float)); //belegt den speicherplatz mit calloc + return matrix; + }else{ + printf("Nullgroesse der Matrix!!!\n"); + Matrix matrix; + matrix.rows = 0; + matrix.cols = 0; + matrix.buffer = NULL; + return matrix; + } } void clearMatrix(Matrix *matrix)