Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
you have to plug the memleaks from time to time
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Nov 2011 21:23:25 +0000 (22:23 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Nov 2011 21:23:25 +0000 (22:23 +0100)
src/surf/surf_routing_cluster.c
src/surf/surf_routing_dijkstra.c
src/surf/surf_routing_full.c
src/surf/surf_routing_generic.c
src/surf/surf_routing_private.h

index d5658b6..2ea9e51 100644 (file)
@@ -41,11 +41,16 @@ static route_extended_t cluster_get_route(AS_t as,
          return new_e_route;
 }
 
+static void model_cluster_finalize(AS_t as) {
+  xbt_dict_free(&cluster_host_link);
+  model_none_finalize(as);
+}
 /* Creation routing model functions */
 AS_t model_cluster_create(void)
 {
   AS_t result = model_none_create();
   result->get_route = cluster_get_route;
+  result->finalize = model_cluster_finalize;
 
   return (AS_t) result;
 }
index 31e59e3..4e51e93 100644 (file)
@@ -417,19 +417,13 @@ static void dijkstra_finalize(AS_t asg)
 {
   as_dijkstra_t as = (as_dijkstra_t) asg;
 
-  if (as) {
-    xbt_graph_free_graph(as->route_graph, &xbt_free,
-                         &graph_edge_data_free, &xbt_free);
-    xbt_dict_free(&as->graph_node_map);
-    if (as->cached)
-      xbt_dict_free(&as->route_cache);
-    /* Delete bypass dict */
-    xbt_dict_free(&as->generic_routing.bypassRoutes);
-    /* Delete index dict */
-    xbt_dict_free(&(as->generic_routing.to_index));
-    /* Delete structure */
-    xbt_free(as);
-  }
+  xbt_graph_free_graph(as->route_graph, &xbt_free,
+      &graph_edge_data_free, &xbt_free);
+  xbt_dict_free(&as->graph_node_map);
+  if (as->cached)
+    xbt_dict_free(&as->route_cache);
+
+  model_generic_finalize(asg);
 }
 
 /* Creation routing model functions */
index 74e7c26..bfc4e41 100644 (file)
@@ -111,12 +111,7 @@ static void full_finalize(AS_t rc)
       for (j = 0; j < table_size; j++)
         generic_free_extended_route(TO_ROUTE_FULL(i, j));
     xbt_free(routing->routing_table);
-    /* Delete bypass dict */
-    xbt_dict_free(&rc->bypassRoutes);
-    /* Delete index dict */
-    xbt_dict_free(&rc->to_index);
-    /* Delete structure */
-    xbt_free(rc);
+    model_generic_finalize(rc);
   }
 }
 
index b985398..4355976 100644 (file)
@@ -27,13 +27,18 @@ 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 = model_none_finalize;
+  new_component->finalize = model_generic_finalize;
+
   new_component->to_index = xbt_dict_new();
   new_component->bypassRoutes = xbt_dict_new();
 
   return new_component;
 }
-
+void model_generic_finalize(AS_t as) {
+  xbt_dict_free(&as->to_index);
+  xbt_dict_free(&as->bypassRoutes);
+  model_none_finalize(as);
+}
 
 void generic_parse_PU(AS_t as, const char *name)
 {
index 778d1e3..e11316e 100644 (file)
@@ -27,6 +27,7 @@ void model_none_finalize(AS_t as);
 /* ************************************************************************** */
 /* ***************** GENERIC PARSE FUNCTIONS (declarations) ***************** */
 AS_t model_generic_create_sized(size_t childsize);
+void model_generic_finalize(AS_t as);
 
 void generic_parse_PU(AS_t rc, const char *name);
 void generic_parse_AS(AS_t rc, const char *name);