From c1cefafb4bbcb85e9285d9172d12feefee4d4b18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20B=C3=A9daride?= Date: Fri, 22 Nov 2013 14:49:24 +0100 Subject: [PATCH] Fix free of uninitialized values --- src/surf/network.hpp | 3 ++- src/surf/surf.hpp | 1 + src/surf/surf_routing.cpp | 13 ++++++++----- src/surf/surf_routing.hpp | 1 + src/surf/surf_routing_cluster.hpp | 2 -- src/surf/surf_routing_full.cpp | 7 +++++-- src/surf/surf_routing_none.hpp | 19 ++++++++++--------- src/surf/workstation_ptask_L07.hpp | 2 ++ 8 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/surf/network.hpp b/src/surf/network.hpp index fda0c0874e..5acdb1216d 100644 --- a/src/surf/network.hpp +++ b/src/surf/network.hpp @@ -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) diff --git a/src/surf/surf.hpp b/src/surf/surf.hpp index c88ca70b05..aaafa54524 100644 --- a/src/surf/surf.hpp +++ b/src/surf/surf.hpp @@ -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; diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index e314b6a37e..211559d5b1 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -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() { diff --git a/src/surf/surf_routing.hpp b/src/surf/surf_routing.hpp index 7d34cbc091..0f73c60b24 100644 --- a/src/surf/surf_routing.hpp +++ b/src/surf/surf_routing.hpp @@ -93,6 +93,7 @@ public: class RoutingPlatf { public: + ~RoutingPlatf(); AsPtr p_root; void *p_loopback; xbt_dynar_t p_lastRoute; diff --git a/src/surf/surf_routing_cluster.hpp b/src/surf/surf_routing_cluster.hpp index c3e887118e..90d13787cb 100644 --- a/src/surf/surf_routing_cluster.hpp +++ b/src/surf/surf_routing_cluster.hpp @@ -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; diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index 84b72a7496..85551c8d39 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -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); } diff --git a/src/surf/surf_routing_none.hpp b/src/surf/surf_routing_none.hpp index 2e6d24aa20..7cc02f355b 100644 --- a/src/surf/surf_routing_none.hpp +++ b/src/surf/surf_routing_none.hpp @@ -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); }; diff --git a/src/surf/workstation_ptask_L07.hpp b/src/surf/workstation_ptask_L07.hpp index 345f7aaea8..043404a8af 100644 --- a/src/surf/workstation_ptask_L07.hpp +++ b/src/surf/workstation_ptask_L07.hpp @@ -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(); -- 2.20.1