forked from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c99205afc2 |
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user