void mpi_type_struct_ (int* count, int* blocklens, int* indices, int* old_types, int* newtype, int* ierr) {
MPI_Datatype tmp;
- auto* types = static_cast<MPI_Datatype*>(xbt_malloc(*count * sizeof(MPI_Datatype)));
- auto* indices_aint = new MPI_Aint[*count];
+ std::vector<MPI_Aint> indices_aint(*count);
+ std::vector<MPI_Datatype> types(*count);
for (int i = 0; i < *count; i++) {
indices_aint[i]=indices[i];
types[i] = simgrid::smpi::Datatype::f2c(old_types[i]);
}
- *ierr = MPI_Type_struct(*count, blocklens, indices_aint, types, &tmp);
+ *ierr = MPI_Type_struct(*count, blocklens, indices_aint.data(), types.data(), &tmp);
if(*ierr == MPI_SUCCESS) {
*newtype = tmp->add_f();
}
- xbt_free(types);
- delete[] indices_aint;
}
void mpi_type_create_struct_(int* count, int* blocklens, MPI_Aint* indices, int* old_types, int* newtype, int* ierr){
MPI_Datatype tmp;
- auto* types = static_cast<MPI_Datatype*>(xbt_malloc(*count * sizeof(MPI_Datatype)));
+ std::vector<MPI_Datatype> types(*count);
for (int i = 0; i < *count; i++) {
types[i] = simgrid::smpi::Datatype::f2c(old_types[i]);
}
- *ierr = MPI_Type_create_struct(*count, blocklens, indices, types, &tmp);
+ *ierr = MPI_Type_create_struct(*count, blocklens, indices, types.data(), &tmp);
if(*ierr == MPI_SUCCESS) {
*newtype = tmp->add_f();
}
- xbt_free(types);
}
void mpi_pack_ (void* inbuf, int* incount, int* type, void* outbuf, int* outcount, int* position, int* comm, int* ierr) {