Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of github.com:mquinson/simgrid
[simgrid.git] / src / instr / jedule / jedule_platform.cpp
index 312b06f..73beb15 100644 (file)
@@ -4,12 +4,14 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include <stdlib.h>
-#include <string.h>
+#include "simgrid/jedule/jedule_platform.h"
+
 #include "xbt/asserts.h"
 #include "xbt/dynar.h"
+#include "xbt/str.h"
 
-#include "simgrid/jedule/jedule_platform.h"
+#include <stdlib.h>
+#include <string.h>
 
 #ifdef HAVE_JEDULE
 
@@ -30,12 +32,6 @@ static void jed_free_container(jed_simgrid_container_t container);
 
 /********************************************************************/
 
-static int compare_hostnames(const void *host1, const void *host2) {
-  const char *hp1 = *((const char**) host1);
-  const char *hp2 = *((const char**) host2);
-  return strcmp (hp1, hp2);
-}
-
 static int compare_ids(const void *num1, const void *num2) {
   int *i1 = (int*) num1;
   int *i2 = (int*) num2;
@@ -97,7 +93,7 @@ void jed_simgrid_add_resources(jed_simgrid_container_t parent,
   parent->last_id = 0;
   parent->resource_list = xbt_dynar_new(sizeof(char *), NULL);
 
-  xbt_dynar_sort (host_names,  &compare_hostnames);
+  xbt_dynar_sort_strings(host_names);
 
   xbt_dynar_foreach(host_names, iter, host_name) {
     buf = bprintf("%d", parent->last_id);
@@ -161,7 +157,7 @@ static void add_subsets_to(xbt_dynar_t subset_list, xbt_dynar_t hostgroup,
   nb_ids = xbt_dynar_length(id_list);
   id_ar = xbt_new0(int,nb_ids);
   xbt_dynar_foreach(id_list, iter, id_str) {
-    id_ar[iter] = atoi(id_str);
+    id_ar[iter] = xbt_str_parse_int(id_str, "Parse error: not a number: %s");
   }
 
   qsort (id_ar, nb_ids, sizeof(int), &compare_ids);