X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/05e321965385feba5537d9f9846426216280b34a..6a6c1a432ee6568c58d74d31746544e6afabdf6f:/src/smpi/smpi_group.c diff --git a/src/smpi/smpi_group.c b/src/smpi/smpi_group.c index b9122e93d2..33f99023c0 100644 --- a/src/smpi/smpi_group.c +++ b/src/smpi/smpi_group.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2013-2014. The SimGrid Team. +/* Copyright (c) 2010, 2013-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -92,9 +92,13 @@ void smpi_group_set_mapping(MPI_Group group, int index, int rank) 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"); + } } } } @@ -111,10 +115,14 @@ int smpi_group_index(MPI_Group group, int rank) 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); + xbt_free(key); + }else + xbt_die("could not allocate memory for asprintf"); if (!ptr_rank) return MPI_UNDEFINED; return *ptr_rank;