X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ef0de8a7383b8ceb975c064c292030f156e346bf..c8d6bade6ee8fff928228bec67e9b2e86484793d:/src/surf/AsImpl.cpp diff --git a/src/surf/AsImpl.cpp b/src/surf/AsImpl.cpp index 36666af8cc..291a79bddd 100644 --- a/src/surf/AsImpl.cpp +++ b/src/surf/AsImpl.cpp @@ -1,19 +1,17 @@ -/* Copyright (c) 2006-2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/log.h" -#include "simgrid/s4u/As.hpp" #include "src/surf/AsImpl.hpp" #include "src/surf/network_interface.hpp" // Link FIXME: move to proper header XBT_LOG_NEW_DEFAULT_SUBCATEGORY(AsImpl,surf, "Implementation of S4U autonomous systems"); namespace simgrid { - namespace surf { + namespace routing { AsImpl::AsImpl(const char *name) : As(name) @@ -21,12 +19,10 @@ namespace simgrid { } AsImpl::~AsImpl() { - xbt_dynar_free(&upDownLinks); - delete netcard_; } xbt_dynar_t AsImpl::getOneLinkRoutes() { - return NULL; + return nullptr; } /** @brief Get the common ancestor and its first childs in each line leading to src and dst */ @@ -50,17 +46,17 @@ namespace simgrid { xbt_assert(dst_as, "Host %s must be in an AS", dst->name()); /* (2) find the path to the root routing component */ - for (AsImpl *current = src_as; current != NULL; current = static_cast(current->father())) { + for (AsImpl *current = src_as; current != nullptr; current = static_cast(current->father())) { xbt_assert(index_src < ROUTING_HIERARCHY_MAXDEPTH, "ROUTING_HIERARCHY_MAXDEPTH should be increased for element %s", src->name()); path_src[index_src++] = current; } - for (AsImpl *current = dst_as; current != NULL; current = static_cast(current->father())) { + for (AsImpl *current = dst_as; current != nullptr; current = static_cast(current->father())) { xbt_assert(index_dst < ROUTING_HIERARCHY_MAXDEPTH,"ROUTING_HIERARCHY_MAXDEPTH should be increased for path_dst"); path_dst[index_dst++] = current; } /* (3) find the common father. - * Before that, index_src and index_dst may be different, they both point to NULL in path_src/path_dst + * Before that, index_src and index_dst may be different, they both point to nullptr in path_src/path_dst * So we move them down simultaneously as long as they point to the same content. */ do { @@ -83,9 +79,9 @@ namespace simgrid { /* PRECONDITION: this is the common ancestor of src and dst */ - std::vector *AsImpl::getBypassRoute(surf::NetCard *src, surf::NetCard *dst) + std::vector *AsImpl::getBypassRoute(routing::NetCard *src, routing::NetCard *dst) { - // If never set a bypass route return NULL without any further computations + // If never set a bypass route return nullptr without any further computations XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name(), dst->name()); if (bypassRoutes_.empty()) return nullptr; @@ -103,14 +99,14 @@ namespace simgrid { /* (2) find the path to the root routing component */ std::vector path_src; As *current = src->containingAS(); - while (current != NULL) { + while (current != nullptr) { path_src.push_back(current); current = current->father_; } std::vector path_dst; current = dst->containingAS(); - while (current != NULL) { + while (current != nullptr) { path_dst.push_back(current); current = current->father_; } @@ -166,9 +162,9 @@ namespace simgrid { * \param src the source host * \param dst the destination host * \param links Where to store the links and the gw information - * \param latency If not NULL, the latency of all links will be added in it + * \param latency If not nullptr, the latency of all links will be added in it */ - void AsImpl::getRouteRecursive(surf::NetCard *src, surf::NetCard *dst, + void AsImpl::getRouteRecursive(routing::NetCard *src, routing::NetCard *dst, /* OUT */ std::vector * links, double *latency) { s_sg_platf_route_cbarg_t route; @@ -205,7 +201,7 @@ namespace simgrid { route.link_list = new std::vector(); common_ancestor->getRouteAndLatency(src_ancestor->netcard_, dst_ancestor->netcard_, &route, latency); - xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL), + xbt_assert((route.gw_src != nullptr) && (route.gw_dst != nullptr), "bad gateways for route from \"%s\" to \"%s\"", src->name(), dst->name()); /* If source gateway is not our source, we have to recursively find our way up to this point */ @@ -213,6 +209,7 @@ namespace simgrid { getRouteRecursive(src, route.gw_src, links, latency); for (auto link: *route.link_list) links->push_back(link); + delete route.link_list; /* If dest gateway is not our destination, we have to recursively find our way from this point */ if (route.gw_dst != dst)