diff --git a/matrix.c b/matrix.c index f67e8e7..d47c550 100644 --- a/matrix.c +++ b/matrix.c @@ -8,6 +8,16 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) { Matrix matrix; + + if(rows == 0 || cols == 0) + { + matrix.rows = 0; + matrix.cols = 0; + matrix.data = NULL; + return matrix; + } + + matrix.rows = rows; matrix.cols = cols; @@ -29,6 +39,7 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) matrix.data[i * matrix.cols + j] = UNDEFINED_MATRIX_VALUE; } } + return matrix; } void clearMatrix(Matrix *matrix) diff --git a/matrix.h b/matrix.h index e10b794..3772325 100644 --- a/matrix.h +++ b/matrix.h @@ -11,6 +11,7 @@ typedef struct Matrix { unsigned int rows; unsigned int cols; MatrixType *data; + #define buffer data } Matrix;