diff --git a/Startcode/matrix.c b/Startcode/matrix.c index 05e5042..3bbcc64 100644 --- a/Startcode/matrix.c +++ b/Startcode/matrix.c @@ -10,9 +10,9 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) matrix.rows = rows; matrix.cols = cols; matrix.buffer = NULL; - if (rows == 0 || cols == 0) + if (matrix.rows == 0 || matrix.cols == 0) { - return; + return matrix; } matrix.buffer = malloc(rows * cols * sizeof(MatrixType)); return matrix; @@ -21,6 +21,7 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) void clearMatrix(Matrix *matrix) { free(matrix->buffer); + matrix->buffer = NULL; } void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)