Author SHA1 Message Date
Angelos c99205afc2 (create und clear Matrix hinzugefügt) 2026-11-12 06:48:15 +01:00
+25
View File
@@ -6,11 +6,36 @@
Matrix createMatrix(unsigned int rows, unsigned int cols)
{
Matrix m;
m.rows = rows;
m.cols = cols;
// Speicher reservieren und mit 0 initialisieren
m.buffer = (MatrixType *)calloc((size_t)rows * cols, sizeof(MatrixType));
// Falls Arbeitsspeicher voll ist
if (m.buffer == NULL) {
m.rows = 0;
m.cols = 0;
}
return m;
}
void clearMatrix(Matrix *matrix)
{
//prüfen ob pointer exisitert und ob es einen buffer gibt
if (matrix != NULL && matrix->buffer != NULL)
{
// Speicher freigeben
free(matrix->buffer);
// Werte zurücksetzen
matrix->buffer = NULL;
matrix->rows = 0;
matrix->cols = 0;
}
}