X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/29aece352b6242fed59d733f405a0c3df0839ca5..25d45f9361e286f1adc9b6efc16b7678d6c1a61b:/examples/smpi/MM/param.c diff --git a/examples/smpi/MM/param.c b/examples/smpi/MM/param.c index af39c21415..0d932fb30b 100644 --- a/examples/smpi/MM/param.c +++ b/examples/smpi/MM/param.c @@ -103,7 +103,8 @@ char** get_conf(MPI_Comm comm, const char * filename, int mynoderank) * we rebuild the line to get every information*/ char* line = NULL; number = 0; - getline(&line,&number,conf); + if (getline(&line,&number,conf) == -1) + xbt_die("Cannot get line"); char* line1 = NULL; asprintf(&line1,"%s %s %s",name,char_index,line); return get_list_param(line1); @@ -128,41 +129,6 @@ char** get_conf(MPI_Comm comm, const char * filename, int mynoderank) } -char*** get_conf_all(char * filename, int * nb_process){ - if(filename == NULL) return NULL; - - char *** all_conf = NULL; - FILE* conf; - int nb_line = 0; - char *line = NULL; - size_t linecap = 0; - ssize_t linelen; - - conf = fopen(filename, "r"); - if (conf == NULL) { - XBT_DEBUG( - "Try to open the configuration file %s\n", filename); - perror("fopen"); - return NULL; - } - - while ((linelen = getline(&line, &linecap, conf)) > 0) - nb_line++; - fclose(conf); - conf = fopen(filename, "r"); - - all_conf = malloc(sizeof(char**) * nb_line); - /* Try to find the line correponding to this processor */ - nb_line = 0; - while ((linelen = getline(&line, &linecap, conf)) > 0){ - if (strcmp(line,"") == 0) continue; //Skip blank line - if (line[0] == '#') continue; //Skip comment line - all_conf[nb_line] = get_list_param(line); - nb_line++; - } - if(nb_process != NULL) *nb_process = nb_line; - return all_conf; -} void print_conf(MPI_Comm comm, int rank, FILE* file, char * default_options){