Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make trivial functions inline.
[simgrid.git] / src / smpi / mpi / smpi_datatype.cpp
index c28c526b3fab63e0f94226234cac60653c4da5bd..a7ea791711d43508f513f32fa16350de7450b832 100644 (file)
@@ -185,6 +185,7 @@ int Datatype::copy_attrs(Datatype* datatype){
       }
     }
   }
+  delete contents_;
   contents_ = new Datatype_contents(MPI_COMBINER_DUP, 0, nullptr, 0, nullptr, 1, &datatype);
   return ret;
 }
@@ -355,7 +356,7 @@ int Datatype::copy(const void* sendbuf, int sendcount, MPI_Datatype sendtype, vo
     int count = sendcount < recvcount ? sendcount : recvcount;
     XBT_DEBUG("Copying %d bytes from %p to %p", count, sendbuf, recvbuf);
     if (not(sendtype->flags() & DT_FLAG_DERIVED) && not(recvtype->flags() & DT_FLAG_DERIVED)) {
-      if (not smpi_process()->replaying())
+      if (not smpi_process()->replaying() && count > 0)
         memcpy(recvbuf, sendbuf, count);
     } else if (not(sendtype->flags() & DT_FLAG_DERIVED)) {
       recvtype->unserialize(sendbuf, recvbuf, count / recvtype->size(), MPI_REPLACE);
@@ -377,14 +378,14 @@ int Datatype::copy(const void* sendbuf, int sendcount, MPI_Datatype sendtype, vo
 //Default serialization method : memcpy.
 void Datatype::serialize(const void* noncontiguous_buf, void* contiguous_buf, int count)
 {
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  const char* noncontiguous_buf_char = static_cast<const char*>(noncontiguous_buf)+lb_;
+  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*size_);
 }
 
 void Datatype::unserialize(const void* contiguous_buf, void *noncontiguous_buf, int count, MPI_Op op){
-  const char* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb_;
+  const auto* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
+  auto* noncontiguous_buf_char    = static_cast<char*>(noncontiguous_buf) + lb_;
   int n=count;
   if(op!=MPI_OP_NULL)
     op->apply( contiguous_buf_char, noncontiguous_buf_char, &n, this);