Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
plug a bunch of memleaks
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 15 Nov 2011 12:14:28 +0000 (13:14 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 15 Nov 2011 12:52:32 +0000 (13:52 +0100)
src/surf/surf_routing.c
src/surf/surf_routing_floyd.c
src/surf/surf_routing_full.c
src/surf/surf_routing_rulebased.c

index a507e10..3a5f19f 100644 (file)
@@ -251,6 +251,7 @@ static void routing_parse_E_route(void)
              "no defined method \"set_route\" in \"%s\"",
              current_routing->name);
   current_routing->parse_route(current_routing, src, dst, route);
+  generic_free_route(route);
   parsed_link_list = NULL;
   src = NULL;
   dst = NULL;
@@ -269,6 +270,7 @@ static void routing_parse_E_ASroute(void)
              "no defined method \"set_ASroute\" in \"%s\"",
              current_routing->name);
   current_routing->parse_ASroute(current_routing, src, dst, e_route);
+  generic_free_route(e_route);
   parsed_link_list = NULL;
   src = NULL;
   dst = NULL;
index a4e1fa3..be0e83e 100644 (file)
@@ -152,8 +152,8 @@ static void floyd_finalize(AS_t rc)
     xbt_dict_free(&(as->generic_routing.to_index));
     /* Delete dictionary index dict, predecessor and links table */
     xbt_free(as->predecessor_table);
-    /* Delete structure */
-    xbt_free(rc);
+
+    model_generic_finalize(rc);
   }
 }
 
index 60dff10..3263bb8 100644 (file)
@@ -251,6 +251,4 @@ void model_full_set_route(AS_t rc, const char *src,
                      xbt_dynar_shrink(TO_ROUTE_FULL(*dst_id, *src_id)->link_list, 0);
                }
        }
-
-       generic_free_route((route_t)route) ;
 }
index 9b7c420..b9fb8c4 100644 (file)
@@ -100,9 +100,11 @@ static void model_rulebased_parse_route(AS_t rc,
   xbt_assert(ruleroute->re_src,
               "PCRE compilation failed at offset %d (\"%s\"): %s\n",
               erroffset, dst, error);
+
   ruleroute->re_str_link = route->link_list;
+  route->link_list = NULL; // Don't free it twice in each container
+
   xbt_dynar_push(routing->list_route, &ruleroute);
-  xbt_free(route);
 }
 
 static void model_rulebased_parse_ASroute(AS_t rc,
@@ -134,9 +136,10 @@ static void model_rulebased_parse_ASroute(AS_t rc,
   ruleroute_e->re_src_gateway = route->src_gateway;
   ruleroute_e->re_dst_gateway = route->dst_gateway;
   xbt_dynar_push(routing->list_ASroute, &ruleroute_e);
-//  xbt_free(route->src_gateway);
-//  xbt_free(route->dst_gateway);
-  xbt_free(route);
+
+  /* make sure that they don't get freed */
+  route->link_list = NULL;
+  route->src_gateway = route->dst_gateway = NULL;
 }
 
 static void model_rulebased_parse_bypassroute(AS_t rc,
@@ -373,8 +376,8 @@ static void rulebased_finalize(AS_t rc)
     xbt_dict_free(&routing->dict_autonomous_systems);
     xbt_dynar_free(&routing->list_route);
     xbt_dynar_free(&routing->list_ASroute);
-    /* Delete structure */
-    xbt_free(routing);
+
+    model_generic_finalize(rc);
   }
 }