- if(datatype->attributes !=NULL){
- (*new_t)->attributes=xbt_dict_new();
- xbt_dict_cursor_t cursor = NULL;
- int *key;
- int flag;
- void* value_in;
- void* value_out;
- xbt_dict_foreach(datatype->attributes, cursor, key, value_in){
- smpi_type_key_elem elem = static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)key, sizeof(int)));
- if(elem && elem->copy_fn!=MPI_NULL_COPY_FN){
- ret = elem->copy_fn(datatype, *key, NULL, value_in, &value_out, &flag );
- if(ret!=MPI_SUCCESS){
- *new_t=MPI_DATATYPE_NULL;
- return ret;
- }
- if(flag)
- xbt_dict_set_ext((*new_t)->attributes, (const char*)key, sizeof(int),value_out, NULL);
+ if(datatype->attributes !=nullptr){
+ (*new_t)->attributes = xbt_dict_new_homogeneous(nullptr);
+ xbt_dict_cursor_t cursor = nullptr;
+ int* key;
+ int flag;
+ void* value_in;
+ void* value_out;
+ xbt_dict_foreach (datatype->attributes, cursor, key, value_in) {
+ smpi_type_key_elem elem = static_cast<smpi_type_key_elem>(
+ xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(key), sizeof(int)));
+ if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) {
+ ret = elem->copy_fn(datatype, *key, nullptr, value_in, &value_out, &flag);
+ if (ret != MPI_SUCCESS) {
+ smpi_datatype_unuse(*new_t);
+ *new_t = MPI_DATATYPE_NULL;
+ xbt_dict_cursor_free(&cursor);
+ return ret;