Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill trailing whitespaces in source code files.
[simgrid.git] / src / smpi / mpi / smpi_datatype_derived.cpp
index b9c9cf7..fa4a389 100644 (file)
@@ -21,6 +21,14 @@ Datatype_contents::Datatype_contents(int combiner, int number_of_integers, const
     , addresses_(addresses, addresses + number_of_addresses)
     , datatypes_(datatypes, datatypes + number_of_datatypes)
 {
+  for (auto& datatype : datatypes_)
+    datatype->ref();
+}
+
+Datatype_contents::~Datatype_contents()
+{
+  for (auto& datatype : datatypes_)
+    Datatype::unref(datatype);
 }
 
 Type_Contiguous::Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type)
@@ -46,7 +54,7 @@ void Type_Contiguous::serialize(const void* noncontiguous_buf, void* contiguous_
 {
   auto* contiguous_buf_char          = static_cast<char*>(contiguous_buf);
   const auto* noncontiguous_buf_char = static_cast<const char*>(noncontiguous_buf) + lb();
-  memcpy(contiguous_buf_char, noncontiguous_buf_char, count * block_count_ * old_type_->size());
+  memcpy(contiguous_buf_char, noncontiguous_buf_char, old_type_->size() * count * block_count_);
 }
 
 void Type_Contiguous::unserialize(const void* contiguous_buf, void* noncontiguous_buf, int count, MPI_Op op)
@@ -237,7 +245,7 @@ Type_Indexed::Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int co
 }
 
 int Type_Indexed::clone(MPI_Datatype* type)
-{ 
+{
   *type = new Type_Indexed(this->size(), this->lb(), this->ub(), this->flags(), this->block_count_, this->block_lengths_, (int*)(this->block_indices_), this->old_type_);
   (*type)->copy_attrs(this);
   return MPI_SUCCESS;