From 81e5658be9c401845c0a1541709e11c7caa0cbd8 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Fri, 24 Jan 2014 11:25:53 +0100 Subject: [PATCH] leak--; dynar abuse--; --- src/surf/surf_routing.cpp | 8 ++++---- src/surf/surf_routing_cluster_torus.cpp | 15 +++++++++++---- src/surf/surf_routing_cluster_torus.hpp | 1 + 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index e5afea3ef9..b2e8bdbdee 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -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("", 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("", 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("", cluster->id); AS.routing = A_surfxml_AS_routing_Cluster; diff --git a/src/surf/surf_routing_cluster_torus.cpp b/src/surf/surf_routing_cluster_torus.cpp index 4f8bbaf39b..851fc2935b 100644 --- a/src/surf/surf_routing_cluster_torus.cpp +++ b/src/surf/surf_routing_cluster_torus.cpp @@ -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){ diff --git a/src/surf/surf_routing_cluster_torus.hpp b/src/surf/surf_routing_cluster_torus.hpp index 995700fdec..39ac2bfa13 100644 --- a/src/surf/surf_routing_cluster_torus.hpp +++ b/src/surf/surf_routing_cluster_torus.hpp @@ -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); -- 2.20.1