X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/87abed69d2734abfc0474c30b6f6d04b25a2c8ac..eaa222acd330e2c3e2c517c5eaab82c8fcb8a4c1:/src/simgrid/host.cpp diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 3c9fe63827..e8ea892a41 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -37,8 +37,12 @@ size_t sg_host_count() */ sg_host_t *sg_host_list() { xbt_assert(sg_host_count() > 0, "There is no host!"); + std::vector hosts = simgrid::s4u::Engine::getInstance()->getAllHosts(); - return (sg_host_t*)xbt_dynar_to_array(sg_hosts_as_dynar()); + sg_host_t* res = (sg_host_t*)malloc(sizeof(sg_host_t) * hosts.size()); + memcpy(res, hosts.data(), sizeof(sg_host_t) * hosts.size()); + + return res; } const char *sg_host_get_name(sg_host_t host) @@ -71,8 +75,7 @@ xbt_dynar_t sg_hosts_as_dynar() { xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t),nullptr); - std::vector list; - simgrid::s4u::Engine::getInstance()->getHostList(&list); + std::vector list = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& host : list) { if (host && host->pimpl_netpoint && host->pimpl_netpoint->isHost())