- val_rank = (int *) malloc(sizeof(int));
- *val_rank = rank;
- int size = asprintf(&key, "%d", index);
- if (size!=-1){
- xbt_dict_set(group->index_to_rank_map, key, val_rank, NULL);
- free(key);
- } else {
- xbt_die("could not allocate memory for asprintf");
- }
+ val_rank = static_cast<int *>(xbt_malloc(sizeof(int)));
+ *val_rank = rank;
+
+ char * key = bprintf("%d", index);
+ xbt_dict_set(group->index_to_rank_map, key, val_rank, nullptr);
+ xbt_free(key);