X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fb33f893495b18dc7a0e13182b901d4cf662150f..22b73e951cc052e33689b42fd9a747334bc22c8a:/src/s4u/s4u_netzone.cpp diff --git a/src/s4u/s4u_netzone.cpp b/src/s4u/s4u_netzone.cpp index 780baadf35..0a343db706 100644 --- a/src/s4u/s4u_netzone.cpp +++ b/src/s4u/s4u_netzone.cpp @@ -38,7 +38,6 @@ NetZone::~NetZone() delete static_cast(elem); } - delete hosts_; xbt_dict_free(&children_); xbt_free(name_); } @@ -76,12 +75,13 @@ NetZone* NetZone::father() std::vector* NetZone::hosts() { - for (auto card : vertices_) { - s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->name()); - if (host != nullptr) - hosts_->push_back(host); - } - return hosts_; + if (hosts_.empty()) // Lazy initialization + for (auto card : vertices_) { + s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->name()); + if (host != nullptr) + hosts_.push_back(host); + } + return &hosts_; } int NetZone::addComponent(kernel::routing::NetPoint* elm)