Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
deprecate a dynar based function
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 11 Mar 2020 09:17:55 +0000 (10:17 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 11 Mar 2020 09:18:34 +0000 (10:18 +0100)
include/simgrid/host.h
src/msg/msg_legacy.cpp
src/s4u/s4u_Host.cpp

index 754a8bc..7a13313 100644 (file)
@@ -27,7 +27,7 @@ XBT_PUBLIC size_t sg_host_count();
  * @remark The host order in the returned array is generally different from the host creation/declaration order in the
  *         XML platform (we use a hash table internally)
  */
-XBT_PUBLIC xbt_dynar_t sg_hosts_as_dynar();
+XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_list()") XBT_PUBLIC xbt_dynar_t sg_hosts_as_dynar();
 
 XBT_PUBLIC size_t sg_host_extension_create(void (*deleter)(void*));
 XBT_PUBLIC void* sg_host_extension_get(const_sg_host_t host, size_t rank);
index f39efe1..6ddae74 100644 (file)
@@ -301,7 +301,15 @@ sg_size_t MSG_storage_write(sg_storage_t storage, sg_size_t size)
 /* ************************** hosts *************************** */
 xbt_dynar_t MSG_hosts_as_dynar()
 {
-  return sg_hosts_as_dynar();
+  size_t host_count = sg_host_count();
+  sg_host_t* list   = sg_host_list();
+
+  xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr);
+  for (size_t i = 0; i < host_count; i++)
+    xbt_dynar_push_as(res, sg_host_t, list[i]);
+  xbt_free(list);
+
+  return res;
 }
 size_t MSG_get_host_number()
 {
index b9b273c..e5edd61 100644 (file)
@@ -350,7 +350,7 @@ sg_host_t sg_host_by_name(const char* name)
   return simgrid::s4u::Host::by_name_or_null(name);
 }
 
-xbt_dynar_t sg_hosts_as_dynar()
+xbt_dynar_t sg_hosts_as_dynar() // XBT_ATTRIB_DEPRECATED_v330
 {
   std::vector<simgrid::s4u::Host*> list = simgrid::s4u::Engine::get_instance()->get_all_hosts();