Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix some memory leack.
[simgrid.git] / teshsuite / simdag / platforms / flatifier.c
index 7285eae..456499c 100644 (file)
@@ -46,8 +46,7 @@ static int name_compare_links(const void *n1, const void *n2)
 int main(int argc, char **argv)
 {
   char *platformFile = NULL;
-  int totalHosts, totalLinks, tmp_length;
-  int j, k;
+  int totalHosts, totalLinks;
   unsigned int i;
   xbt_dict_t props = NULL;
   xbt_dict_cursor_t cursor = NULL;
@@ -57,20 +56,20 @@ int main(int argc, char **argv)
   xbt_ex_t e;
 
   const SD_workstation_t *hosts;
-  const SD_link_t *links, *tmp;
+  const SD_link_t *links;
 
   SD_init(&argc, argv);
 
   platformFile = argv[1];
-  DEBUG1("%s", platformFile);
+  XBT_DEBUG("%s", platformFile);
   TRY {
     SD_create_environment(platformFile);
   } CATCH(e) {
-    xbt_die(bprintf("Error while loading %s: %s",platformFile,e.msg));     
+    xbt_die("Error while loading %s: %s",platformFile,e.msg);
   }
 
   printf("<?xml version='1.0'?>\n");
-  printf("<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n");
+  printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n");
   printf("<platform version=\"3\">\n");
   printf("<AS id=\"AS0\" routing=\"Full\">\n");
 
@@ -85,7 +84,7 @@ int main(int argc, char **argv)
            SD_workstation_get_name(hosts[i]),
            SD_workstation_get_power(hosts[i]));
     props = SD_workstation_get_properties(hosts[i]);
-    if (xbt_dict_length(props) > 0) {
+    if (props && xbt_dict_length(props) > 0) {
       printf(">\n");
       xbt_dict_foreach(props, cursor, key, data) {
         printf("    <prop id=\"%s\" value=\"%s\"/>\n", key, data);
@@ -149,6 +148,7 @@ int main(int argc, char **argv)
 
                                        char *link_name = bprintf("%s",((surf_resource_t) link)->name);
                                        printf("<link_ctn id=\"%s\"/>",link_name);
+                                       free(link_name);
                                }
                                printf("\n  </route>\n");