diff --git a/info2praktikum-neuronalesnetz/matrix.c b/info2praktikum-neuronalesnetz/matrix.c index 2563a0e..d3037b6 100644 --- a/info2praktikum-neuronalesnetz/matrix.c +++ b/info2praktikum-neuronalesnetz/matrix.c @@ -10,10 +10,15 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) Matrix matrix; matrix.rows = rows; matrix.cols = cols; - matrix.buffer = (float *)malloc(rows * cols * sizeof(MatrixType)); - if (matrix.buffer != NULL) { - + if(matrix.rows == 0 || matrix.cols == 0){ + matrix.rows = 0; + matrix.cols = 0; + matrix.buffer = NULL; + } + else { + matrix.buffer = (float *)malloc(rows * cols * sizeof(MatrixType)); } + return matrix; }