Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dont segfault when exiting before everything is allocated (as on parse errors)
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 4 Apr 2015 12:56:03 +0000 (14:56 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 4 Apr 2015 12:57:37 +0000 (14:57 +0200)
src/surf/surf_routing_floyd.cpp

index 7d4e942..e87df4f 100644 (file)
@@ -33,16 +33,19 @@ AsFloyd::~AsFloyd(){
   int i, j;
   int table_size;
   table_size = (int)xbt_dynar_length(p_indexNetworkElm);
-    /* Delete link_table */
-    for (i = 0; i < table_size; i++)
-      for (j = 0; j < table_size; j++)
-        generic_free_route(TO_FLOYD_LINK(i, j));
-    xbt_free(p_linkTable);
-    /* Delete bypass dict */
-    xbt_dict_free(&p_bypassRoutes);
-    /* Delete predecessor and cost table */
-    xbt_free(p_predecessorTable);
-    xbt_free(p_costTable);
+  if (p_linkTable == NULL) // Dealing with a parse error in the file?
+         return;
+  /* Delete link_table */
+  for (i = 0; i < table_size; i++)
+         for (j = 0; j < table_size; j++) {
+                 generic_free_route(TO_FLOYD_LINK(i, j));
+         }
+  xbt_free(p_linkTable);
+  /* Delete bypass dict */
+  xbt_dict_free(&p_bypassRoutes);
+  /* Delete predecessor and cost table */
+  xbt_free(p_predecessorTable);
+  xbt_free(p_costTable);
 }
 
 /* Business methods */