forked from freudenreichan/info2Praktikum-NeuronalesNetz
createM FailsOnZeroDim, beheben
This commit is contained in:
1 parent
9d3b503ec8
commit
1720536667
1 file changed
+7
@@ -9,6 +9,13 @@ Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||
Matrix m;
|
||||
m.rows = rows;
|
||||
m.cols = cols;
|
||||
|
||||
if(rows == 0|| cols == 0) // Zeile oder Spalte = 0, dann keine Speicher anfordern, sonder Buffer auf NULL setzen
|
||||
{
|
||||
m.buffer = NULL;
|
||||
return m;
|
||||
}
|
||||
|
||||
m.buffer = (MatrixType*) calloc(rows * cols, sizeof(MatrixType)); // calloc, statt malloc benutzt, um direkt alle Werte mit 0 zu initialisieren
|
||||
return m;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user