summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/channels.h2
-rw-r--r--src/channels.cpp8
2 files changed, 5 insertions, 5 deletions
diff --git a/include/channels.h b/include/channels.h
index eeb2501fa..2b7c5d025 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -39,7 +39,7 @@ class CoreExport Channel : public Extensible, public InviteBase<Channel>
public:
/** A map of Memberships on a channel keyed by User pointers
*/
- typedef std::map<User*, Membership*> MemberMap;
+ typedef std::map<User*, insp::aligned_storage<Membership> > MemberMap;
private:
/** Set default modes for the channel on creation
diff --git a/src/channels.cpp b/src/channels.cpp
index 13595c4c3..2ea8688cf 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -61,11 +61,11 @@ void Channel::SetTopic(User* u, const std::string& ntopic)
Membership* Channel::AddUser(User* user)
{
- Membership*& memb = userlist[user];
- if (memb)
+ std::pair<MemberMap::iterator, bool> ret = userlist.insert(std::make_pair(user, insp::aligned_storage<Membership>()));
+ if (!ret.second)
return NULL;
- memb = new Membership(user, this);
+ Membership* memb = new(ret.first->second) Membership(user, this);
return memb;
}
@@ -102,7 +102,7 @@ void Channel::DelUser(const MemberMap::iterator& membiter)
{
Membership* memb = membiter->second;
memb->cull();
- delete memb;
+ memb->~Membership();
userlist.erase(membiter);
// If this channel became empty then it should be removed