Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a variable to see if having set a bypass route or not.
[simgrid.git] / src / surf / surf_routing_generic.c
index b3fbf54..55be68e 100644 (file)
@@ -14,6 +14,8 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
 
+static int having_set_bypassroute = 0;
+
 AS_t model_generic_create_sized(size_t childsize) {
   AS_t new_component = model_none_create_sized(childsize);
 
@@ -28,8 +30,8 @@ AS_t model_generic_create_sized(size_t childsize) {
       generic_get_bypassroute;
   new_component->finalize = model_generic_finalize;
 
-  new_component->to_index = xbt_dict_new();
-  new_component->bypassRoutes = xbt_dict_new();
+  new_component->to_index = xbt_dict_new_homogeneous(xbt_free);
+  new_component->bypassRoutes = xbt_dict_new_homogeneous((void (*)(void *)) generic_free_route);
 
   return new_component;
 }
@@ -46,7 +48,7 @@ void generic_parse_PU(AS_t as, const char *name)
   xbt_dict_t _to_index;
   _to_index = as->to_index;
   *id = xbt_dict_length(_to_index);
-  xbt_dict_set(_to_index, name, id, xbt_free);
+  xbt_dict_set(_to_index, name, id, NULL);
 }
 
 void generic_parse_AS(AS_t as, const char *name)
@@ -56,7 +58,7 @@ void generic_parse_AS(AS_t as, const char *name)
   xbt_dict_t _to_index;
   _to_index = as->to_index;
   *id = xbt_dict_length(_to_index);
-  xbt_dict_set(_to_index, name, id, xbt_free);
+  xbt_dict_set(_to_index, name, id, NULL);
 }
 
 void generic_parse_bypassroute(AS_t rc,
@@ -80,8 +82,8 @@ void generic_parse_bypassroute(AS_t rc,
   xbt_dynar_free(&(e_route->link_list));
   xbt_free(e_route);
 
-  xbt_dict_set(dict_bypassRoutes, route_name, new_e_route,
-               (void (*)(void *)) generic_free_route);
+  xbt_dict_set(dict_bypassRoutes, route_name, new_e_route, NULL);
+  having_set_bypassroute = 1;
   xbt_free(route_name);
 }
 
@@ -90,10 +92,15 @@ void generic_parse_bypassroute(AS_t rc,
 
 xbt_dynar_t generic_get_onelink_routes(AS_t rc) { // FIXME: kill that stub
   xbt_die("\"generic_get_onelink_routes\" not implemented yet");
+  return NULL;
 }
 
 route_t generic_get_bypassroute(AS_t rc, const char *src, const char *dst)
 {
+  // If never set a bypass route return NULL
+  if(!having_set_bypassroute)
+    return NULL;
+
   xbt_dict_t dict_bypassRoutes = rc->bypassRoutes;
   AS_t src_as, dst_as;
   int index_src, index_dst;