Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove useless new/delete (please sonar).
[simgrid.git] / src / smpi / mpi / smpi_datatype_derived.cpp
index 924c02d..0b4a906 100644 (file)
@@ -136,12 +136,11 @@ Type_Hindexed::Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int
     , block_indices_(new MPI_Aint[count])
     , old_type_(old_type)
 {
-  auto* ints = new int[count + 1];
+  std::vector<int> ints(count + 1);
   ints[0]=count;
   for(int i=1;i<=count;i++)
     ints[i]=block_lengths[i-1];
-  contents_ = new Datatype_contents(MPI_COMBINER_HINDEXED, count+1, ints, count, block_indices, 1, &old_type);
-  delete[] ints;
+  contents_ = new Datatype_contents(MPI_COMBINER_HINDEXED, count + 1, ints.data(), count, block_indices, 1, &old_type);
   old_type_->ref();
   for (int i = 0; i < count; i++) {
     block_lengths_[i] = block_lengths[i];
@@ -230,14 +229,13 @@ Type_Indexed::Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int co
     : Type_Hindexed(size, lb, ub, flags, count, block_lengths, block_indices, old_type, old_type->get_extent())
 {
   delete contents_;
-  auto* ints = new int[2 * count + 1];
+  std::vector<int> ints(2 * count + 1);
   ints[0]=count;
   for(int i=1;i<=count;i++)
     ints[i]=block_lengths[i-1];
   for(int i=count+1;i<=2*count;i++)
     ints[i]=block_indices[i-count-1];
-  contents_ = new Datatype_contents(MPI_COMBINER_INDEXED, 2*count+1, ints, 0, nullptr, 1, &old_type);
-  delete[] ints;
+  contents_ = new Datatype_contents(MPI_COMBINER_INDEXED, 2 * count + 1, ints.data(), 0, nullptr, 1, &old_type);
 }
 
 int Type_Indexed::clone(MPI_Datatype* type)
@@ -255,12 +253,12 @@ Type_Struct::Type_Struct(int size, MPI_Aint lb, MPI_Aint ub, int flags, int coun
     , block_indices_(new MPI_Aint[count])
     , old_types_(new MPI_Datatype[count])
 {
-  auto* ints = new int[count + 1];
+  std::vector<int> ints(count + 1);
   ints[0]=count;
   for(int i=1;i<=count;i++)
     ints[i]=block_lengths[i-1];
-  contents_ = new Datatype_contents(MPI_COMBINER_INDEXED, count+1, ints, count, block_indices, count, old_types);
-  delete[] ints;
+  contents_ =
+      new Datatype_contents(MPI_COMBINER_INDEXED, count + 1, ints.data(), count, block_indices, count, old_types);
   for (int i = 0; i < count; i++) {
     block_lengths_[i]=block_lengths[i];
     block_indices_[i]=block_indices[i];