Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
plug a memleak when the cluster's router_id is not given
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Nov 2011 13:22:01 +0000 (14:22 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Nov 2011 13:22:01 +0000 (14:22 +0100)
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index fc81aae..0df0989 100644 (file)
@@ -1611,13 +1611,19 @@ void routing_parse_Scluster(void)
   }
   xbt_dynar_free(&radical_elements);
 
-  //Make the router
+  // Add a router. It is magically used thanks to the way in which surf_routing_cluster is written, and it's very useful to connect clusters together
   XBT_DEBUG(" ");
   XBT_DEBUG("<router id=\"%s\"/>", struct_cluster->router_id);
-  SURFXML_BUFFER_SET(router_id, struct_cluster->router_id);
-  SURFXML_BUFFER_SET(router_coordinates, "");
-  SURFXML_START_TAG(router);
-  SURFXML_END_TAG(router);
+  s_sg_platf_router_cbarg_t router;
+  char *newid=NULL;
+  memset(&router,0,sizeof(router));
+  router.id = struct_cluster->router_id;
+  router.coord = "";
+  if (!router.id || !strcmp(router.id,""))
+    router.id = newid = bprintf("%s%s_router%s", struct_cluster->prefix, struct_cluster->id, struct_cluster->suffix);
+  sg_platf_new_router(&router);
+  if (newid)
+    free(newid);
 
   //Make the backbone
   if( (struct_cluster->bb_bw!= 0)  && (struct_cluster->bb_lat!=0)  ){
@@ -1642,7 +1648,7 @@ void routing_parse_Scluster(void)
          }
 
          sg_platf_new_link(&link);
-         ETag_surfxml_link();
+         ETag_surfxml_link();//FIXME: killme
 
          surf_parsing_link_up_down_t info = xbt_new0(s_surf_parsing_link_up_down_t, 1);
          info->link_up   = xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL);
index 950173c..915dfd7 100644 (file)
@@ -321,13 +321,7 @@ void STag_surfxml_cluster(void){
          struct_cluster->bb_bw = surf_parse_get_double(A_surfxml_cluster_bb_bw);
        if(strcmp(A_surfxml_cluster_bb_lat,""))
          struct_cluster->bb_lat = surf_parse_get_double(A_surfxml_cluster_bb_lat);
-       if(!strcmp(A_surfxml_cluster_router_id,""))
-               struct_cluster->router_id = bprintf("%s%s_router%s",
-                               struct_cluster->prefix,
-                               struct_cluster->id,
-                               struct_cluster->suffix);
-       else
-               struct_cluster->router_id = A_surfxml_cluster_router_id;
+       struct_cluster->router_id = A_surfxml_cluster_router_id;
 
        struct_cluster->sharing_policy = AX_surfxml_cluster_sharing_policy;
        struct_cluster->bb_sharing_policy = AX_surfxml_cluster_bb_sharing_policy;