From: Gabriel Corona Date: Fri, 15 Jan 2016 15:05:52 +0000 (+0100) Subject: [s4u] Use const& references in Host::mounted_storages() X-Git-Tag: v3_13~1232 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fbb7ac75c324bca94e2033d95f5420ca2aa5708e [s4u] Use const& references in Host::mounted_storages() --- diff --git a/examples/s4u/io/s4u_io_test.cpp b/examples/s4u/io/s4u_io_test.cpp index bc0eb0e0c0..c2e9757b5f 100644 --- a/examples/s4u/io/s4u_io_test.cpp +++ b/examples/s4u/io/s4u_io_test.cpp @@ -16,7 +16,7 @@ public: myHost(const char*procname, simgrid::s4u::Host *host,int argc, char **argv) : simgrid::s4u::Actor(procname,host,argc,argv){} - void show_info(boost::unordered_map &mounts) { + void show_info(boost::unordered_map const&mounts) { XBT_INFO("Storage info on %s:", simgrid::s4u::Host::current()->name().c_str()); @@ -35,7 +35,7 @@ public: } int main(int argc, char **argv) { - boost::unordered_map & mounts = + boost::unordered_map const& mounts = simgrid::s4u::Host::current()->mounted_storages(); show_info(mounts); diff --git a/include/simgrid/s4u/host.hpp b/include/simgrid/s4u/host.hpp index 10b6bc974a..be70679e2f 100644 --- a/include/simgrid/s4u/host.hpp +++ b/include/simgrid/s4u/host.hpp @@ -81,10 +81,8 @@ public: /** Get an associative list [mount point]->[Storage] off all local mount points. * * This is defined in the platform file, and cannot be modified programatically (yet). - * - * Do not change the returned value in any way. */ - boost::unordered_map &mounted_storages(); + boost::unordered_map const &mounted_storages(); private: simgrid::xbt::string name_ = "noname"; diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index 615ac8b3e0..48b517621a 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -76,7 +76,7 @@ int Host::pstates_count() const { return this->pimpl_cpu->getNbPStates(); } -boost::unordered_map &Host::mounted_storages() { +boost::unordered_map const& Host::mounted_storages() { if (mounts == NULL) { mounts = new boost::unordered_map ();