Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix free of uninitialized values
authorPaul Bédaride <paul.bedaride@gmail.com>
Fri, 22 Nov 2013 13:49:24 +0000 (14:49 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Fri, 22 Nov 2013 13:49:24 +0000 (14:49 +0100)
src/surf/network.hpp
src/surf/surf.hpp
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/surf_routing_cluster.hpp
src/surf/surf_routing_full.cpp
src/surf/surf_routing_none.hpp
src/surf/workstation_ptask_L07.hpp

index fda0c08..5acdb12 100644 (file)
@@ -49,7 +49,8 @@ public:
     this->initialize();
   }
   ~NetworkCm02Model() {
-       lmm_system_free(p_maxminSystem);
+       if (p_maxminSystem)
+         lmm_system_free(p_maxminSystem);
        if (p_actionHeap)
          xbt_heap_free(p_actionHeap);
        if (p_modifiedSet)
index c88ca70..aaafa54 100644 (file)
@@ -214,6 +214,7 @@ public:
                            tmgr_trace_t state_trace,
                            double metric_peak,
                            tmgr_trace_t metric_trace);
+  ~ResourceLmm() {};
   lmm_constraint_t p_constraint;
   tmgr_trace_event_t p_stateEvent;
   s_surf_metric_t p_power;
index e314b6a..211559d 100644 (file)
@@ -1263,11 +1263,14 @@ 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);
-  delete routing_platf;
+  if (routing_platf)
+    delete routing_platf;
+}
+
+RoutingPlatf::~RoutingPlatf()
+{
+       xbt_dynar_free(&p_lastRoute);
+       finalize_rec(p_root);
 }
 
 AS_t surf_AS_get_routing_root() {
index 7d34cbc..0f73c60 100644 (file)
@@ -93,6 +93,7 @@ public:
 
 class RoutingPlatf {
 public:
+  ~RoutingPlatf();
   AsPtr p_root;
   void *p_loopback;
   xbt_dynar_t p_lastRoute;
index c3e8871..90d1378 100644 (file)
@@ -33,8 +33,6 @@ public:
   int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
   int parseAS(RoutingEdgePtr elm);
 
-  //virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
-
   NetworkCm02LinkPtr p_backbone;
   void *p_loopback;
   RoutingEdgePtr p_router;
index 84b72a7..85551c8 100644 (file)
@@ -61,8 +61,11 @@ AsFull::~AsFull(){
   /* Delete routing table */
   for (i = 0; i < table_size; i++)
     for (j = 0; j < table_size; j++) {
-      xbt_dynar_free(&TO_ROUTE_FULL(i,j)->link_list);
-      xbt_free(TO_ROUTE_FULL(i,j));
+      if (TO_ROUTE_FULL(i,j)){
+       if (TO_ROUTE_FULL(i,j)->link_list)
+          xbt_dynar_free(&TO_ROUTE_FULL(i,j)->link_list);
+        xbt_free(TO_ROUTE_FULL(i,j));
+      }
     }
   xbt_free(p_routingTable);
 }
index 2e6d24a..7cc02f3 100644 (file)
@@ -7,20 +7,21 @@ class AsNone : public As {
 public:
   AsNone();
   ~AsNone();
-  virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
-  virtual xbt_dynar_t getOneLinkRoutes();
-  virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
-  virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
+
+  void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
+  xbt_dynar_t getOneLinkRoutes();
+  void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
+  sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
 
   /* The parser calls the following functions to inform the routing models
    * that a new element is added to the AS currently built.
    *
    * Of course, only the routing model of this AS is informed, not every ones */
-  virtual int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
-  virtual int parseAS( RoutingEdgePtr elm);
-  virtual void parseRoute(sg_platf_route_cbarg_t route);
-  virtual void parseASroute(sg_platf_route_cbarg_t route);
-  virtual void parseBypassroute(sg_platf_route_cbarg_t e_route);
+  int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
+  int parseAS( RoutingEdgePtr elm);
+  void parseRoute(sg_platf_route_cbarg_t route);
+  void parseASroute(sg_platf_route_cbarg_t route);
+  void parseBypassroute(sg_platf_route_cbarg_t e_route);
 };
 
 
index 345f7aa..043404a 100644 (file)
@@ -141,6 +141,8 @@ public:
 class LinkL07 : public NetworkCm02LinkLmm {
 public:
   LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props);
+  ~LinkL07(){
+  };
   bool isUsed();
   void updateState(tmgr_trace_event_t event_type, double value, double date);
   double getBandwidth();