From: Frederic Suter Date: Tue, 5 Dec 2017 08:23:52 +0000 (+0100) Subject: allStorages() -> getStorageList(whereTo) X-Git-Tag: v3.18~148 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0628f0debd3f323fd216a191295ed5778f5f235c allStorages() -> getStorageList(whereTo) --- diff --git a/ChangeLog b/ChangeLog index 22c53c2315..f18d137b43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ SimGrid (3.18) NOT RELEASED YET (target: December 24 2017) Mailbox::getCname() instead to get a char*. - Storage::getName() changed to return a std::string, use Storage::getCname() instead to get a char*. + - simgrid::s4u::allStorages() becomes + simgrid::s4u::getStorageList(whereTo) to have both allocation + and deallocation of the map in user space. MSG - Deprecate MSG_task_get_flops_amount(). Its semantic was weird: diff --git a/examples/s4u/io-file-remote/s4u-io-file-remote.cpp b/examples/s4u/io-file-remote/s4u-io-file-remote.cpp index 13b59de07d..5ec1825408 100644 --- a/examples/s4u/io-file-remote/s4u-io-file-remote.cpp +++ b/examples/s4u/io-file-remote/s4u-io-file-remote.cpp @@ -58,7 +58,8 @@ int main(int argc, char** argv) e.loadPlatform(argv[1]); e.registerFunction("host", host); e.loadDeployment(argv[2]); - std::map* allStorages = simgrid::s4u::allStorages(); + std::map* allStorages = new std::map; + simgrid::s4u::getStorageList(allStorages); for (auto const& s : *allStorages) { XBT_INFO("Init: %llu/%llu MiB used/free on '%s'", sg_storage_get_size_used(s.second) / INMEGA, diff --git a/include/simgrid/s4u/Storage.hpp b/include/simgrid/s4u/Storage.hpp index f313e494a2..571c3b1d92 100644 --- a/include/simgrid/s4u/Storage.hpp +++ b/include/simgrid/s4u/Storage.hpp @@ -21,7 +21,7 @@ extern template class XBT_PUBLIC() Extendable; } namespace s4u { -XBT_ATTRIB_PUBLIC std::map* allStorages(); +XBT_ATTRIB_PUBLIC void getStorageList(std::map* whereTo); XBT_PUBLIC_CLASS Storage : public simgrid::xbt::Extendable { diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index aff1939d78..0734919388 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -93,11 +93,12 @@ msg_storage_t MSG_storage_get_by_name(const char *name) */ xbt_dynar_t MSG_storages_as_dynar() { - std::map* storage_map = simgrid::s4u::allStorages(); + std::map* storage_list = new std::map; + simgrid::s4u::getStorageList(storage_list); xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),nullptr); - for (auto const& s : *storage_map) + for (auto const& s : *storage_list) xbt_dynar_push(res, &(s.second)); - delete storage_map; + delete storage_list; return res; } diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index b4920f5a15..d8f004ac63 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -17,14 +17,10 @@ template class Extendable; namespace s4u { -std::map* allStorages() +void getStorageList(std::map* whereTo) { - std::unordered_map* map = surf::StorageImpl::storagesMap(); - std::map* res = new std::map; - for (auto const& s : *map) - res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface - - return res; + for (auto const& s : *surf::StorageImpl::storagesMap()) + whereTo->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface } Storage* Storage::byName(std::string name) diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index 9eb3c0323c..1f14a3e873 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -90,7 +90,8 @@ static void get_set_storage_data(const std::string& storage_name) static void dump_platform_storages() { - std::map* storages = simgrid::s4u::allStorages(); + std::map* storages = new std::map; + simgrid::s4u::getStorageList(storages); for (auto const& storage : *storages) { XBT_INFO("Storage %s is attached to %s", storage.first.c_str(), storage.second->getHost()->getCname());