From: Arnaud Giersch Date: Tue, 2 Mar 2021 10:09:32 +0000 (+0100) Subject: Use std::copy. X-Git-Tag: v3.27~286 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/635dcbeadaecca14d9a4e6c8f3cf76dcd28adf01 Use std::copy. --- diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index bfe5c6726d..39234b52f9 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -318,7 +318,7 @@ sg_host_t* sg_host_list() std::vector hosts = e->get_all_hosts(); sg_host_t* res = xbt_new(sg_host_t, hosts.size()); - memcpy(res, hosts.data(), sizeof(sg_host_t) * hosts.size()); + std::copy(begin(hosts), end(hosts), res); return res; } @@ -395,9 +395,8 @@ void sg_host_get_disks(const_sg_host_t host, unsigned int* disk_count, sg_disk_t { std::vector list = host->get_disks(); *disk_count = list.size(); - *disks = static_cast(xbt_malloc(sizeof(sg_disk_t) * (*disk_count))); - for (size_t i = 0; i < *disk_count; i++) - (*disks)[i] = list[i]; + *disks = xbt_new(sg_disk_t, list.size()); + std::copy(begin(list), end(list), *disks); } // =========== user-level functions ===============