Addressed reviewer's comments.

This commit is contained in:
Markus Blatt 2019-10-18 16:21:02 +02:00
parent 0bc1630cc9
commit 42247105bf

View File

@ -286,7 +286,7 @@ void pack(const char* str, std::vector<char>& buffer, int& position,
std::size_t length = strlen(str)+1; std::size_t length = strlen(str)+1;
MPI_Pack(&length, 1, Dune::MPITraits<std::size_t>::getType(), buffer.data(), MPI_Pack(&length, 1, Dune::MPITraits<std::size_t>::getType(), buffer.data(),
buffer.size(), &position, comm); buffer.size(), &position, comm);
MPI_Pack(str, strlen(str)+1, MPI_CHAR, buffer.data(), buffer.size(), MPI_Pack(str, strlen(str)+1, MPI_CHAR, buffer.data(), buffer.size(),
&position, comm); &position, comm);
#endif #endif
} }
@ -486,11 +486,10 @@ void unpack(std::string& str, std::vector<char>& buffer, int& position,
{ {
std::size_t length=0; std::size_t length=0;
unpack(length, buffer, position, comm); unpack(length, buffer, position, comm);
char* cStr = new char[length]; std::vector<char> cStr(length, '\0');
unpack(cStr, length, buffer, position, comm); unpack(cStr.data(), length, buffer, position, comm);
assert(str.empty()); assert(str.empty());
str.append(cStr); str.append(cStr.data());
delete[] cStr;
} }
template<class T1, class T2> template<class T1, class T2>