Compare commits

..
5 Commits
2 changed files with 5 additions and 3 deletions

No files matched your search

+3 -3
View File
@@ -30,7 +30,7 @@
#define FILE_HEADER_STRING "__info2_image_file_format__" #define FILE_HEADER_STRING "__info2_image_file_format__"
// --------------------------------------------------------- // ---------------------------------------------------------
// Hilfsfunktionen (static, nur in diesem Modul sichtbar) // Hilfsfunktionen
// --------------------------------------------------------- // ---------------------------------------------------------
/** /**
@@ -47,7 +47,7 @@ static int checkFileHeader(FILE *file) {
return 0; // Lesefehler oder Datei zu kurz return 0; // Lesefehler oder Datei zu kurz
} }
// Null-Terminierung sicherstellen für strcmp (obwohl wir auch memcmp nutzen könnten) // Null-Terminierung sicherstellen für strcmp
buffer[headerLen] = '\0'; buffer[headerLen] = '\0';
if (strcmp(buffer, expectedHeader) != 0) { if (strcmp(buffer, expectedHeader) != 0) {
@@ -73,7 +73,7 @@ static GrayScaleImageSeries *allocateSeries(unsigned short count) {
series->labels = (unsigned char *)calloc(count, sizeof(unsigned char)); series->labels = (unsigned char *)calloc(count, sizeof(unsigned char));
if (series->images == NULL || series->labels == NULL) { if (series->images == NULL || series->labels == NULL) {
// Falls eine Allokation fehlschlägt, alles bisherige freigeben // Falls eine Allokation fehlschlägt, alles Bisherigen freigeben
free(series->images); free(series->images);
free(series->labels); free(series->labels);
free(series); free(series);
+2
View File
@@ -114,6 +114,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
return createMatrix(0, 0); return createMatrix(0, 0);
} }
for(unsigned int i = 0; i < resRows; ++i) for(unsigned int i = 0; i < resRows; ++i)
{ {
for(unsigned int j = 0; j < resCols; ++j) for(unsigned int j = 0; j < resCols; ++j)
@@ -124,6 +125,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
unsigned int i2 = (matrix2.rows == 1) ? 0 : i; unsigned int i2 = (matrix2.rows == 1) ? 0 : i;
unsigned int j2 = (matrix2.cols == 1) ? 0 : j; unsigned int j2 = (matrix2.cols == 1) ? 0 : j;
MatrixType val = getMatrixAt(matrix1, i1, j1) + getMatrixAt(matrix2, i2, j2); MatrixType val = getMatrixAt(matrix1, i1, j1) + getMatrixAt(matrix2, i2, j2);
setMatrixAt(val, &result, i, j); setMatrixAt(val, &result, i, j);
} }