-int Comm::keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval,
- void* extra_state){
- if(keyvals_==nullptr)
- keyvals_ = xbt_dict_new_homogeneous(nullptr);
-
- smpi_comm_key_elem value = static_cast<smpi_comm_key_elem>(xbt_new0(s_smpi_mpi_comm_key_elem_t,1));
-
- value->copy_fn=copy_fn;
- value->delete_fn=delete_fn;
-
- *keyval = keyval_id_;
- xbt_dict_set_ext(keyvals_, reinterpret_cast<const char*>(keyval), sizeof(int),static_cast<void*>(value), nullptr);
- keyval_id_++;
- return MPI_SUCCESS;
-}
-
-int Comm::keyval_free(int* keyval){
- smpi_comm_key_elem elem =
- static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(keyvals_, reinterpret_cast<const char*>(keyval), sizeof(int)));
- if(elem==nullptr)
- return MPI_ERR_ARG;
- xbt_dict_remove_ext(keyvals_, reinterpret_cast<const char*>(keyval), sizeof(int));
- xbt_free(elem);
- return MPI_SUCCESS;
-}
-
-void Comm::keyval_cleanup(){
- if(Comm::keyvals_!=nullptr)
- xbt_dict_free(&Comm::keyvals_);
-}
-