From 1b7a0677b5a4eae8e546d7bb90da6ca6c7e4c0fd Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 10 Nov 2011 21:39:19 +0100 Subject: [PATCH] Use the none routing as an ancestor to the generic one, which is ancestor to most of the others. First step to further factorization --- src/surf/surf_routing_generic.c | 4 ++-- src/surf/surf_routing_none.c | 15 ++++++++------- src/surf/surf_routing_private.h | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/surf/surf_routing_generic.c b/src/surf/surf_routing_generic.c index 406f77190a..b985398ca9 100644 --- a/src/surf/surf_routing_generic.c +++ b/src/surf/surf_routing_generic.c @@ -15,7 +15,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing"); AS_t model_generic_create_sized(size_t childsize) { - AS_t new_component = xbt_malloc0(childsize); + AS_t new_component = model_none_create_sized(childsize); new_component->parse_PU = generic_parse_PU; new_component->parse_AS = generic_parse_AS; @@ -27,7 +27,7 @@ AS_t model_generic_create_sized(size_t childsize) { new_component->get_onelink_routes = NULL; new_component->get_bypass_route = generic_get_bypassroute; - new_component->finalize = NULL; + new_component->finalize = model_none_finalize; new_component->to_index = xbt_dict_new(); new_component->bypassRoutes = xbt_dict_new(); diff --git a/src/surf/surf_routing_none.c b/src/surf/surf_routing_none.c index c6394d85b0..a48d9aedc1 100644 --- a/src/surf/surf_routing_none.c +++ b/src/surf/surf_routing_none.c @@ -28,9 +28,8 @@ static route_extended_t none_get_bypass_route(AS_t rc, return NULL; } -static void none_finalize(AS_t rc) -{ - xbt_free(rc); +void model_none_finalize(AS_t as) { + xbt_free(as); } static void none_parse_PU(AS_t rc, @@ -44,9 +43,11 @@ static void none_parse_AS(AS_t rc, } /* Creation routing model functions */ -AS_t model_none_create(void) -{ - AS_t new_component = xbt_new(s_as_t, 1); +AS_t model_none_create() { + return model_none_create_sized(sizeof(s_as_t)); +} +AS_t model_none_create_sized(size_t childsize) { + AS_t new_component = xbt_malloc0(childsize); new_component->parse_PU = none_parse_PU; new_component->parse_AS = none_parse_AS; new_component->parse_route = NULL; @@ -55,7 +56,7 @@ AS_t model_none_create(void) new_component->get_route = none_get_route; new_component->get_onelink_routes = none_get_onelink_routes; new_component->get_bypass_route = none_get_bypass_route; - new_component->finalize = none_finalize; + new_component->finalize = model_none_finalize; return new_component; } diff --git a/src/surf/surf_routing_private.h b/src/surf/surf_routing_private.h index f4bca9c67f..778d1e32a3 100644 --- a/src/surf/surf_routing_private.h +++ b/src/surf/surf_routing_private.h @@ -22,7 +22,8 @@ /* ******************************* NO ROUTING ******************************* */ /* Only save the AS tree, and forward calls to child ASes */ AS_t model_none_create(void); - +AS_t model_none_create_sized(size_t childsize); +void model_none_finalize(AS_t as); /* ************************************************************************** */ /* ***************** GENERIC PARSE FUNCTIONS (declarations) ***************** */ AS_t model_generic_create_sized(size_t childsize); -- 2.20.1