From: thiery Date: Tue, 7 Dec 2010 15:05:20 +0000 (+0000) Subject: Call elements_father() only if necessary X-Git-Tag: v3.6_beta2~856 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e7d5d130145e7983fa9fa90500f2c6dd59b943ea Call elements_father() only if necessary git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9067 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index ba89057986..22a1362b7a 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -875,14 +875,19 @@ static xbt_dynar_t get_route(const char *src, const char *dst) { route_extended_t e_route; - xbt_dynar_t elem_father_list = elements_father(src, dst); - routing_component_t common_father = - xbt_dynar_get_as(elem_father_list, 0, routing_component_t); + xbt_dynar_t elem_father_list = NULL; + routing_component_t common_father = NULL; if (strcmp(src, dst)) e_route = _get_route(src, dst); - else + else { + elem_father_list = elements_father(src, dst); + common_father = + xbt_dynar_get_as(elem_father_list, 0, routing_component_t); + e_route = (*(common_father->get_route)) (common_father, src, dst); + xbt_dynar_free(&elem_father_list); + } xbt_assert2(e_route, "no route between \"%s\" and \"%s\"", src, dst); @@ -896,7 +901,6 @@ static xbt_dynar_t get_route(const char *src, const char *dst) xbt_free(e_route->dst_gateway); xbt_free(e_route); - xbt_dynar_free(&elem_father_list); /* if (xbt_dynar_length(global_routing->last_route) == 0)