Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / smpi / mpi / smpi_info.cpp
index 564b22f..9dbfa70 100644 (file)
@@ -1,14 +1,22 @@
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2022. 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. */
 
 #include "smpi_info.hpp"
+#include "smpi_comm.hpp"
 #include "simgrid/Exception.hpp"
 
 namespace simgrid {
 namespace smpi {
 
+Info::Info(const Info* orig)
+{
+  if (orig != nullptr)
+    map_ = orig->map_;
+  this->add_f();
+}
+
 void Info::ref()
 {
   refcount_++;
@@ -17,11 +25,13 @@ void Info::ref()
 void Info::unref(Info* info){
   info->refcount_--;
   if(info->refcount_==0){
+    F2C::free_f(info->f2c_id());
     delete info;
   }
 }
 
-int Info::get(const char *key, int valuelen, char *value, int *flag){
+int Info::get(const char* key, int valuelen, char* value, int* flag) const
+{
   *flag=false;
   auto val = map_.find(key);
   if (val != map_.end()) {
@@ -42,12 +52,14 @@ int Info::remove(const char *key){
     return MPI_SUCCESS;
 }
 
-int Info::get_nkeys(int *nkeys){
+int Info::get_nkeys(int* nkeys) const
+{
   *nkeys = map_.size();
   return MPI_SUCCESS;
 }
 
-int Info::get_nthkey(int n, char *key){
+int Info::get_nthkey(int n, char* key) const
+{
   int num=0;
   for (auto const& elm : map_) {
     if (num == n) {
@@ -59,7 +71,8 @@ int Info::get_nthkey(int n, char *key){
   return MPI_ERR_ARG;
 }
 
-int Info::get_valuelen(const char *key, int *valuelen, int *flag){
+int Info::get_valuelen(const char* key, int* valuelen, int* flag) const
+{
   *flag=false;
   auto val = map_.find(key);
   if (val != map_.end()) {