Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / smpi / bindings / smpi_f77_comm.cpp
index aafd435..c769b62 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -8,6 +8,8 @@
 #include "smpi_errhandler.hpp"
 #include "smpi_info.hpp"
 
+#include <string>
+
 extern "C" { // This should really use the C linkage to be usable from Fortran
 
 void mpi_comm_rank_(int* comm, int* rank, int* ierr) {
@@ -77,9 +79,9 @@ void mpi_comm_get_attr_ (int* comm, int* comm_keyval, int *attribute_val, int *f
 }
 
 void mpi_comm_set_attr_ (int* comm, int* comm_keyval, int *attribute_val, int* ierr){
int* val = (int*)xbt_malloc(sizeof(int));
*val=*attribute_val;
*ierr = MPI_Comm_set_attr ( simgrid::smpi::Comm::f2c(*comm), *comm_keyval, val);
 auto* val = static_cast<int*>(xbt_malloc(sizeof(int)));
 *val      = *attribute_val;
 *ierr     = MPI_Comm_set_attr(simgrid::smpi::Comm::f2c(*comm), *comm_keyval, val);
 }
 
 void mpi_comm_delete_attr_ (int* comm, int* comm_keyval, int* ierr){
@@ -146,11 +148,8 @@ void mpi_comm_set_name_ (int* comm, char* name, int* ierr){
  int count;
  for(count=MPI_MAX_OBJECT_NAME-1; count>=0 && name[count]==' '; count--);
  count+=1;
- char* tname = xbt_new(char, count+1);
- strncpy(tname, name, count);
- tname[count]='\0';
- *ierr = MPI_Comm_set_name (simgrid::smpi::Comm::f2c(*comm), tname);
- xbt_free(tname);
+ std::string tname(name, count);
+ *ierr = MPI_Comm_set_name(simgrid::smpi::Comm::f2c(*comm), tname.c_str());
 }
 
 void mpi_comm_dup_with_info_ (int* comm, int* info, int* newcomm, int* ierr){