Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't increase refcount when existing elem is overwritten.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 22 May 2021 20:15:05 +0000 (22:15 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 25 May 2021 14:59:28 +0000 (16:59 +0200)
src/smpi/include/smpi_keyvals.hpp

index 8017f09..ab07655 100644 (file)
@@ -131,10 +131,11 @@ template <typename T> int Keyval::attr_put(int keyval, void* attr_value){
     return MPI_ERR_ARG;
 
   smpi_key_elem& elem = elem_it->second;
-  elem.refcount++;
   int flag=0;
   auto p  = attributes().emplace(keyval, attr_value);
-  if (not p.second) {
+  if (p.second) {
+    elem.refcount++;
+  } else {
     int ret = call_deleter<T>((T*)this, elem, keyval,p.first->second,&flag);
     // overwrite previous value
     p.first->second = attr_value;