if (index!=MPI_UNDEFINED ) {
val_rank = (int *) malloc(sizeof(int));
*val_rank = rank;
- asprintf(&key, "%d", index);
- xbt_dict_set(group->index_to_rank_map, key, val_rank, NULL);
- free(key);
+ 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");
+ }
}
}
}
int smpi_group_rank(MPI_Group group, int index)
{
- int * ptr_rank;
+ int * ptr_rank = NULL;
char * key;
- asprintf(&key, "%d", index);
- ptr_rank = xbt_dict_get_or_null(group->index_to_rank_map, key);
+ int size = asprintf(&key, "%d", index);
+ if (size!=-1)
+ ptr_rank = xbt_dict_get_or_null(group->index_to_rank_map, key);
+ else
+ xbt_die("could not allocate memory for asprintf");
if (!ptr_rank)
return MPI_UNDEFINED;
return *ptr_rank;
static xbt_dynar_t get_reqq_self(){
char * key;
- asprintf(&key, "%d", smpi_process_index());
+ int size = asprintf(&key, "%d", smpi_process_index());
+ if(size==-1)
+ xbt_die("could not allocate memory for asprintf");
xbt_dynar_t dynar_mpi_request = (xbt_dynar_t) xbt_dict_get(reqq, key);
free(key);
static void set_reqq_self(xbt_dynar_t mpi_request){
char * key;
- asprintf(&key, "%d", smpi_process_index());
+ int size = asprintf(&key, "%d", smpi_process_index());
+ if(size==-1)
+ xbt_die("could not allocate memory for asprintf");
xbt_dict_set(reqq, key, mpi_request, free);
free(key);
}