X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/73a7fe0ba8650c65f6a7712a4e2b6c9057eac6ac..f50c785a8f726657dc3b4e32de522a7b3baca707:/src/smpi/smpi_keyvals.hpp diff --git a/src/smpi/smpi_keyvals.hpp b/src/smpi/smpi_keyvals.hpp index 0508f33392..74c7722e9a 100644 --- a/src/smpi/smpi_keyvals.hpp +++ b/src/smpi/smpi_keyvals.hpp @@ -47,6 +47,7 @@ class Keyval{ template int attr_get(int keyval, void* attr_value, int* flag); template int attr_put(int keyval, void* attr_value); template static int call_deleter(T* obj, smpi_key_elem elem, int keyval, void * value, int* flag); + template void cleanup_attr(); }; template int Keyval::keyval_create(smpi_copy_fn copy_fn, smpi_delete_fn delete_fn, int* keyval, void* extra_state){ @@ -138,6 +139,22 @@ template int Keyval::attr_put(int keyval, void* attr_value){ return MPI_SUCCESS; } +template void Keyval::cleanup_attr(){ + if(!attributes_.empty()){ + int flag; + for(auto it = attributes_.begin(); it != attributes_.end(); it++){ + try{ + smpi_key_elem elem = T::keyvals_.at((*it).first); + if(elem != nullptr){ + call_deleter((T*)this, elem, (*it).first,(*it).second,&flag); + } + }catch(const std::out_of_range& oor) { + //already deleted, not a problem; + } + } + } +} + } }