Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / smpi / include / smpi_keyvals.hpp
index dc7dd35..7fd5e30 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. 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. */
@@ -35,7 +35,7 @@ struct s_smpi_key_elem_t {
   int refcount;
 };
 
-typedef s_smpi_key_elem_t* smpi_key_elem;
+using smpi_key_elem = s_smpi_key_elem_t*;
 
 namespace simgrid{
 namespace smpi{
@@ -56,14 +56,15 @@ class Keyval{
     template <typename T> int attr_delete(int keyval);
     template <typename T> int attr_get(int keyval, void* attr_value, int* flag);
     template <typename T> int attr_put(int keyval, void* attr_value);
-    template <typename T> static int call_deleter(T* obj, smpi_key_elem elem, int keyval, void * value, int* flag);
+    template <typename T>
+    static int call_deleter(T* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* flag);
     template <typename T> void cleanup_attr();
 };
 
 template <typename T>
 int Keyval::keyval_create(const smpi_copy_fn& copy_fn, const smpi_delete_fn& delete_fn, int* keyval, void* extra_state)
 {
-  smpi_key_elem value = new s_smpi_key_elem_t;
+  auto* value = new s_smpi_key_elem_t;
 
   value->copy_fn=copy_fn;
   value->delete_fn=delete_fn;
@@ -80,7 +81,7 @@ template <typename T> int Keyval::keyval_free(int* keyval){
 /* See MPI-1, 5.7.1.  Freeing the keyval does not remove it if it
          * is in use in an attribute */
   smpi_key_elem elem = T::keyvals_.at(*keyval);
-  if(elem==0){
+  if (elem == nullptr) {
     return MPI_ERR_ARG;
   }
   if(elem->refcount==1){
@@ -112,7 +113,7 @@ template <typename T> int Keyval::attr_delete(int keyval){
 
 
 template <typename T> int Keyval::attr_get(int keyval, void* attr_value, int* flag){
-  smpi_key_elem elem = T::keyvals_.at(keyval);
+  const s_smpi_key_elem_t* elem = T::keyvals_.at(keyval);
   if(elem==nullptr)
     return MPI_ERR_ARG;
   if(attributes()->empty()){
@@ -158,7 +159,7 @@ template <typename T> void Keyval::cleanup_attr(){
           call_deleter<T>((T*)this, elem, it.first,it.second,&flag);
         }
       } else {
-        //already deleted, not a problem;
+        // already deleted, not a problem
         flag=0;
       }
     }