matrix: use stack allocation for debug output string

This commit is contained in:
Matthias Grob 2023-03-07 14:57:07 +01:00
parent b1435c6e34
commit 9f8fa99d70
2 changed files with 9 additions and 14 deletions

View File

@ -367,10 +367,9 @@ public:
{
// element: tab, point, 8 digits, 4 scientific notation chars; row: newline; string: \0 end
static const size_t n = 15 * N * M + M + 1;
char *buf = new char[n];
write_string(buf, n);
printf("%s\n", buf);
delete[] buf;
char string[n];
write_string(string, n);
printf("%s\n", string);
}
Matrix<Type, N, M> transpose() const
@ -817,11 +816,9 @@ OStream &operator<<(OStream &os, const matrix::Matrix<Type, M, N> &matrix)
os << "\n";
// element: tab, point, 8 digits, 4 scientific notation chars; row: newline; string: \0 end
static const size_t n = 15 * N * M + M + 1;
char *buf = new char[n];
matrix.write_string(buf, n);
os << buf;
delete[] buf;
char string[n];
matrix.write_string(string, n);
os << string;
return os;
}

View File

@ -161,11 +161,9 @@ OStream &operator<<(OStream &os, const matrix::Vector<Type, M> &vector)
os << "\n";
// element: tab, point, 8 digits, 4 scientific notation chars; row: newline; string: \0 end
static const size_t n = 15 * M * 1 + 1 + 1;
char *buf = new char[n];
vector.transpose().write_string(buf, n);
os << buf;
delete[] buf;
char string[n];
vector.transpose().write_string(string, n);
os << string;
return os;
}