From: Arnaud Giersch Date: Wed, 25 Sep 2019 19:35:42 +0000 (+0200) Subject: Use plain pointers in internal structures, and hopefully fix more memory leaks. X-Git-Tag: v3.24~62 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b130b354872c90b8103859b2bcaa1f1bcb7f0967 Use plain pointers in internal structures, and hopefully fix more memory leaks. --- diff --git a/src/smpi/include/smpi_group.hpp b/src/smpi/include/smpi_group.hpp index e033edc007..96078433a8 100644 --- a/src/smpi/include/smpi_group.hpp +++ b/src/smpi/include/smpi_group.hpp @@ -20,8 +20,8 @@ class Group : public F2C{ /* This is actually a map from int to int. We could use std::map here, but looking up a value there costs O(log(n)). * For a vector, this costs O(1). We hence go with the vector. */ - std::vector rank_to_actor_map_; - std::map actor_to_rank_map_; + std::vector rank_to_actor_map_; + std::map actor_to_rank_map_; std::vector index_to_rank_map_; int refcount_ = 1; /* refcount_: start > 0 so that this group never gets freed */ @@ -33,7 +33,7 @@ public: void set_mapping(s4u::ActorPtr actor, int rank); int rank(int index); s4u::ActorPtr actor(int rank); - int rank(const s4u::ActorPtr process); + int rank(s4u::ActorPtr process); void ref(); static void unref(MPI_Group group); int size() { return size_; } diff --git a/src/smpi/mpi/smpi_group.cpp b/src/smpi/mpi/smpi_group.cpp index 68d86f8032..eea8e737a9 100644 --- a/src/smpi/mpi/smpi_group.cpp +++ b/src/smpi/mpi/smpi_group.cpp @@ -28,8 +28,9 @@ Group::Group(Group* origin) } } -void Group::set_mapping(s4u::ActorPtr actor, int rank) +void Group::set_mapping(s4u::ActorPtr actor_ptr, int rank) { + s4u::Actor* actor = actor_ptr.get(); if (0 <= rank && rank < size_) { int index = actor->get_pid(); if (index != MPI_UNDEFINED) { @@ -39,9 +40,7 @@ void Group::set_mapping(s4u::ActorPtr actor, int rank) } rank_to_actor_map_[rank] = actor; - if (actor != nullptr) { - actor_to_rank_map_.insert({actor, rank}); - } + actor_to_rank_map_.insert({actor, rank}); } } @@ -64,9 +63,9 @@ s4u::ActorPtr Group::actor(int rank) return nullptr; } -int Group::rank(const s4u::ActorPtr actor) +int Group::rank(s4u::ActorPtr actor) { - auto iterator = actor_to_rank_map_.find(actor); + auto iterator = actor_to_rank_map_.find(actor.get()); return (iterator == actor_to_rank_map_.end()) ? MPI_UNDEFINED : (*iterator).second; }