Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
leak--; dynar abuse--;
authorAugustin Degomme <degomme@idpann.imag.fr>
Fri, 24 Jan 2014 10:25:53 +0000 (11:25 +0100)
committerAugustin Degomme <degomme@idpann.imag.fr>
Fri, 24 Jan 2014 10:31:30 +0000 (11:31 +0100)
src/surf/surf_routing.cpp
src/surf/surf_routing_cluster_torus.cpp
src/surf/surf_routing_cluster_torus.hpp

index e5afea3..b2e8bdb 100644 (file)
@@ -831,10 +831,10 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
   AS.id = cluster->id;
 
   if(cluster->topology == SURF_CLUSTER_TORUS){
-      XBT_DEBUG("<AS id=\"%s\"\trouting=\"Torus_Cluster\">", cluster->id);
-      AS.routing = A_surfxml_AS_routing_Cluster___torus;
-      sg_platf_new_AS_begin(&AS);
-      ((AsClusterTorusPtr)current_routing)->parse_specific_arguments(cluster);
+    XBT_DEBUG("<AS id=\"%s\"\trouting=\"Torus_Cluster\">", cluster->id);
+    AS.routing = A_surfxml_AS_routing_Cluster___torus;
+    sg_platf_new_AS_begin(&AS);
+    ((AsClusterTorusPtr)current_routing)->parse_specific_arguments(cluster);
   }else{
     XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", cluster->id);
     AS.routing = A_surfxml_AS_routing_Cluster;
index 4f8bbaf..851fc29 100644 (file)
@@ -28,6 +28,11 @@ AsClusterTorus::AsClusterTorus() : AsCluster()
   p_dimensions = NULL;
 }
 
+/* Creation routing model functions */
+AsClusterTorus::~AsClusterTorus()
+{
+  if(p_dimensions) xbt_dynar_free(&p_dimensions);
+}
 
 
 void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position){
@@ -88,23 +93,25 @@ void AsClusterTorus::parse_specific_arguments(sg_platf_cluster_cbarg_t cluster){
 
   unsigned int iter;
   char *groups;
-  p_dimensions = xbt_str_split(cluster->topo_parameters, ",");
+  xbt_dynar_t dimensions = xbt_str_split(cluster->topo_parameters, ",");
 
-    if (!xbt_dynar_is_empty(p_dimensions)) {
+    if (!xbt_dynar_is_empty(dimensions)) {
+      p_dimensions= xbt_dynar_new(sizeof(int), NULL);
       /**
        * We are in a torus cluster
        * Parse attribute dimensions="dim1,dim2,dim3,...,dimN"
        * and safe it in a dynarray.
        * Additionally, we need to know how many ranks we have in total
        */
-      xbt_dynar_foreach(p_dimensions, iter, groups) {
-          int tmp = surf_parse_get_int(xbt_dynar_get_as(p_dimensions, iter, char *));
+      xbt_dynar_foreach(dimensions, iter, groups) {
+          int tmp = surf_parse_get_int(xbt_dynar_get_as(dimensions, iter, char *));
           xbt_dynar_set_as(p_dimensions, iter, int, tmp);
       }
 
       p_nb_links_per_node = xbt_dynar_length(p_dimensions);
 
     }
+    xbt_dynar_free(&dimensions);
 }
 
 void AsClusterTorus::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat){
index 995700f..39ac2bf 100644 (file)
@@ -13,6 +13,7 @@ typedef AsClusterTorus *AsClusterTorusPtr;
 class AsClusterTorus: public AsCluster {
 public:
    AsClusterTorus();
+   virtual ~AsClusterTorus();
    virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position);
    virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
    void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster);