Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use the none routing as an ancestor to the generic one, which is ancestor to most...
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Nov 2011 20:39:19 +0000 (21:39 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Nov 2011 20:39:19 +0000 (21:39 +0100)
src/surf/surf_routing_generic.c
src/surf/surf_routing_none.c
src/surf/surf_routing_private.h

index 406f771..b985398 100644 (file)
@@ -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();
 
index c6394d8..a48d9ae 100644 (file)
@@ -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;
 }
 
index f4bca9c..778d1e3 100644 (file)
@@ -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);