X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e1a5484101efbff9c8d982a0c4650f7953ee7e2f..6260d187764dc644d699e1a53454f7efdcc682df:/src/smpi/mpi/smpi_info.cpp diff --git a/src/smpi/mpi/smpi_info.cpp b/src/smpi/mpi/smpi_info.cpp index 33be51967c..0d696f4796 100644 --- a/src/smpi/mpi/smpi_info.cpp +++ b/src/smpi/mpi/smpi_info.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2023. 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. */ @@ -7,8 +7,14 @@ #include "smpi_comm.hpp" #include "simgrid/Exception.hpp" -namespace simgrid { -namespace smpi { +namespace simgrid::smpi { + +Info::Info(const Info* orig) +{ + if (orig != nullptr) + map_ = orig->map_; + this->add_f(); +} void Info::ref() { @@ -26,8 +32,7 @@ void Info::unref(Info* info){ int Info::get(const char* key, int valuelen, char* value, int* flag) const { *flag=false; - auto val = map_.find(key); - if (val != map_.end()) { + if (auto val = map_.find(key); val != map_.end()) { std::string tmpvalue = val->second; memset(value, 0, valuelen); @@ -54,9 +59,9 @@ int Info::get_nkeys(int* nkeys) const int Info::get_nthkey(int n, char* key) const { int num=0; - for (auto const& elm : map_) { + for (auto const& [elm, _] : map_) { if (num == n) { - strncpy(key, elm.first.c_str(), elm.first.length() + 1); + strncpy(key, elm.c_str(), elm.length() + 1); return MPI_SUCCESS; } num++; @@ -67,8 +72,7 @@ int Info::get_nthkey(int n, char* key) const int Info::get_valuelen(const char* key, int* valuelen, int* flag) const { *flag=false; - auto val = map_.find(key); - if (val != map_.end()) { + if (auto val = map_.find(key); val != map_.end()) { *valuelen = val->second.length(); *flag=true; } @@ -79,5 +83,4 @@ Info* Info::f2c(int id){ return static_cast(F2C::f2c(id)); } -} -} +} // namespace simgrid::smpi