Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix Memleaks
[simgrid.git] / src / surf / surf_routing.cpp
index d667710..cb3672c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
+/* Copyright (c) 2009, 2010, 2011, 2013. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -132,7 +132,7 @@ static void parse_S_host_link(sg_platf_host_link_cbarg_t host)
     current_routing->p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
 
   // If dynar is is greater than edge id and if the host_link is already defined
-  if(xbt_dynar_length(current_routing->p_linkUpDownList) > info->m_id &&
+  if((int)xbt_dynar_length(current_routing->p_linkUpDownList) > info->m_id &&
       xbt_dynar_get_as(current_routing->p_linkUpDownList, info->m_id, void*))
     xbt_die("Host_link for '%s' is already defined!",host->id);
 
@@ -397,7 +397,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
 
   info->p_rcComponent = new_as->p_routingFather;
   info->p_rcType = SURF_NETWORK_ELEMENT_AS;
-  info->p_name = new_as->p_name;
+  info->p_name = xbt_strdup(new_as->p_name);
 
   xbt_lib_set(as_router_lib, info->p_name, ROUTING_ASR_LEVEL,
               (void *) info);
@@ -420,7 +420,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
  * even if you add stuff to a closed AS
  *
  */
-void routing_AS_end(sg_platf_AS_cbarg_t AS)
+void routing_AS_end(sg_platf_AS_cbarg_t /*AS*/)
 {
 
   if (current_routing == NULL) {
@@ -542,7 +542,7 @@ static void _get_route_and_latency(RoutingEdgePtr src, RoutingEdgePtr dst,
   /* Common ancestor is kind enough to declare a bypass route from src to dst -- use it and bail out */
   if (e_route_bypass) {
     xbt_dynar_merge(links, &e_route_bypass->link_list);
-    //FIXME:generic_free_route(e_route_bypass);
+    generic_free_route(e_route_bypass);
     return;
   }
 
@@ -1263,11 +1263,13 @@ static void finalize_rec(AsPtr as) {
 
 /** \brief Frees all memory allocated by the routing module */
 void routing_exit(void) {
-  if (!routing_platf)
-    return;
-  xbt_dynar_free(&routing_platf->p_lastRoute);
-  finalize_rec(routing_platf->p_root);
-  xbt_free(routing_platf);
+  delete routing_platf;
+}
+
+RoutingPlatf::~RoutingPlatf()
+{
+       xbt_dynar_free(&p_lastRoute);
+       finalize_rec(p_root);
 }
 
 AS_t surf_AS_get_routing_root() {