first fail fixed

This commit is contained in:
Simon 2025-11-08 14:59:27 +01:00
parent c560fd5241
commit 5b5e1182bd
2 changed files with 26 additions and 29 deletions

View File

@ -6,14 +6,12 @@
Matrix createMatrix(unsigned int rows, unsigned int cols)
{
Matrix m;
Matrix m = {0, 0, NULL};
m.buffer = NULL;
if (rows > 0 && cols > 0)
{
m.rows = rows;
m.cols = cols;
if (rows > 0 || cols > 0)
{
m.buffer = malloc(rows * cols * sizeof(int));
}
@ -23,7 +21,8 @@ Matrix createMatrix(unsigned int rows, unsigned int cols)
void clearMatrix(Matrix *matrix)
{
if (matrix == NULL) {
if (matrix == NULL)
{
return;
}
@ -75,7 +74,6 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
for (unsigned int j = 0; j < result.cols; j++)
{
result.buffer[i * result.cols + j] = matrix1.buffer[i * matrix1.cols + j] + matrix2.buffer[i * matrix2.cols + j];
}
}
return result;

View File

@ -11,7 +11,6 @@ typedef struct
{
unsigned int rows; // Anzahl der Zeilen
unsigned int cols; // Anzahl der Spalten
//void *buffer;
MatrixType *buffer; // Zeiger auf die Matrixdaten
} Matrix;