Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into fix/execute_benched
[simgrid.git] / examples / simdag / dag-dotload / sd_dag-dotload.c
index a2006ba..7dfd2f0 100644 (file)
@@ -1,6 +1,6 @@
 /* simple test trying to load a DOT file.                                   */
 
-/* Copyright (c) 2010-2015. The SimGrid Team.
+/* Copyright (c) 2010-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -9,7 +9,6 @@
 #include "simgrid/simdag.h"
 #include "xbt/log.h"
 #include <stdio.h>
-#include <string.h>
 #include <libgen.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this SimDag example");
@@ -34,14 +33,13 @@ int main(int argc, char **argv)
   dot = SD_dotload(argv[2]);
   if(dot == NULL){
     XBT_CRITICAL("No dot loaded. Do you have a cycle in your graph?");
-    SD_exit();
     exit(2);
   }
 
   char *tracefilename;
   char *last = strrchr(argv[2], '.');
   tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]);
-  if (argc == 4) 
+  if (argc == 4)
     tracefilename = xbt_strdup(argv[3]);
 
   /* Display all the tasks */
@@ -60,17 +58,18 @@ int main(int argc, char **argv)
 
   /* Schedule them all on the first workstation */
   XBT_INFO("------------------- Schedule tasks ---------------------------");
-  const sg_host_t *ws_list = sg_host_list();
+  sg_host_t *hosts = sg_host_list();
 
   int count = sg_host_count();
   xbt_dynar_foreach(dot, cursor, task) {
     if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
       if (!strcmp(SD_task_get_name(task), "end"))
-        SD_task_schedulel(task, 1, ws_list[0]);
+        SD_task_schedulel(task, 1, hosts[0]);
       else
-        SD_task_schedulel(task, 1, ws_list[cursor % count]);
+        SD_task_schedulel(task, 1, hosts[cursor % count]);
     }
   }
+  xbt_free(hosts);
 
   XBT_INFO("------------------- Run the schedule ---------------------------");
   SD_simulate(-1);
@@ -96,7 +95,7 @@ int main(int argc, char **argv)
           sg_host_get_name(wsl[0]), sg_host_get_name(wsl[1]), SD_task_get_amount(task), SD_task_get_name(task));
       break;
     default:
-      xbt_die("Task %s is of unknown kind %d", SD_task_get_name(task), SD_task_get_kind(task));
+      xbt_die("Task %s is of unknown kind %u", SD_task_get_name(task), SD_task_get_kind(task));
     }
     SD_task_destroy(task);
   }
@@ -104,6 +103,5 @@ int main(int argc, char **argv)
   fclose(out);
 
   /* exit */
-  SD_exit();
   return 0;
 }