diff options
-rw-r--r-- | include/modules/bs_badwords.h | 1 | ||||
-rw-r--r-- | modules/commands/bs_badwords.cpp | 12 | ||||
-rw-r--r-- | modules/commands/cs_entrymsg.cpp | 42 | ||||
-rw-r--r-- | modules/commands/cs_log.cpp | 7 | ||||
-rw-r--r-- | modules/commands/cs_mode.cpp | 15 | ||||
-rw-r--r-- | modules/commands/ns_ajoin.cpp | 17 |
6 files changed, 68 insertions, 26 deletions
diff --git a/include/modules/bs_badwords.h b/include/modules/bs_badwords.h index 4275226cc..8791b8812 100644 --- a/include/modules/bs_badwords.h +++ b/include/modules/bs_badwords.h @@ -32,6 +32,7 @@ struct BadWord Anope::string word; BadWordType type; + virtual ~BadWord() { } protected: BadWord() { } }; diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index ff9707778..b64ed9b59 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -35,6 +35,8 @@ struct BadWordsImpl : BadWords BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), badwords("BadWord") { } + ~BadWordsImpl(); + BadWord* AddBadWord(const Anope::string &word, BadWordType type) anope_override { BadWordImpl *bw = new BadWordImpl(); @@ -87,6 +89,16 @@ struct BadWordsImpl : BadWords } }; +BadWordsImpl::~BadWordsImpl() +{ + for (list::iterator it = badwords->begin(); it != badwords->end();) + { + BadWord *bw = *it; + ++it; + delete bw; + } +} + BadWordImpl::~BadWordImpl() { ChannelInfo *ci = ChannelInfo::Find(chan); diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index d3d3bb71b..ca521a82c 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -26,6 +26,8 @@ struct EntryMsg : Serializable this->when = ct; } + ~EntryMsg(); + void Serialize(Serialize::Data &data) const anope_override { data["ci"] << this->ci->name; @@ -43,11 +45,23 @@ struct EntryMessageList : Serialize::Checker<std::vector<EntryMsg *> > ~EntryMessageList() { - for (unsigned i = 0; i < (*this)->size(); ++i) - delete (*this)->at(i); + for (unsigned i = (*this)->size(); i > 0; --i) + delete (*this)->at(i - 1); } }; +EntryMsg::~EntryMsg() +{ + EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg"); + if (messages) + { + std::vector<EntryMsg *>::iterator it = std::find((*messages)->begin(), (*messages)->end(), this); + if (it != (*messages)->end()) + (*messages)->erase(it); + } +} + + Serializable* EntryMsg::Unserialize(Serializable *obj, Serialize::Data &data) { Anope::string sci, screator, smessage; @@ -71,9 +85,7 @@ Serializable* EntryMsg::Unserialize(Serializable *obj, Serialize::Data &data) return msg; } - EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg"); - if (messages == NULL) - messages = ci->Extend<EntryMessageList>("entrymsg"); + EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg"); data["when"] >> swhen; @@ -87,9 +99,7 @@ class CommandEntryMessage : public Command private: void DoList(CommandSource &source, ChannelInfo *ci) { - EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg"); - if (messages == NULL) - messages = ci->Extend<EntryMessageList>("entrymsg"); + EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg"); if ((*messages)->empty()) { @@ -123,9 +133,7 @@ class CommandEntryMessage : public Command void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &message) { - EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg"); - if (messages == NULL) - messages = ci->Extend<EntryMessageList>("entrymsg"); + EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg"); if ((*messages)->size() >= Config->GetModule(this->owner)->Get<unsigned>("maxentries")) source.Reply(_("The entry message list for \002%s\002 is full."), ci->name.c_str()); @@ -139,9 +147,7 @@ class CommandEntryMessage : public Command void DoDel(CommandSource &source, ChannelInfo *ci, const Anope::string &message) { - EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg"); - if (messages == NULL) - messages = ci->Extend<EntryMessageList>("entrymsg"); + EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg"); if (!message.is_pos_number_only()) source.Reply(("Entry message \002%s\002 not found on channel \002%s\002."), message.c_str(), ci->name.c_str()); @@ -155,7 +161,6 @@ class CommandEntryMessage : public Command if (i > 0 && i <= (*messages)->size()) { delete (*messages)->at(i - 1); - (*messages)->erase((*messages)->begin() + i - 1); if ((*messages)->empty()) ci->Shrink<EntryMessageList>("entrymsg"); Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message"; @@ -246,14 +251,15 @@ class CommandEntryMessage : public Command class CSEntryMessage : public Module { - Serialize::Type entrymsg_type; CommandEntryMessage commandentrymsg; + Serialize::Type entrymsg_type; ExtensibleItem<EntryMessageList> eml; public: - CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), entrymsg_type("EntryMsg", EntryMsg::Unserialize), commandentrymsg(this), eml(this, "entrymsg") + CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), + commandentrymsg(this), eml(this, "entrymsg"), + entrymsg_type("EntryMsg", EntryMsg::Unserialize) { - } void OnJoinChannel(User *u, Channel *c) anope_override diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index 96d959e2c..d93dcf8a2 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -277,8 +277,8 @@ class CSLog : public Module { ServiceReference<MemoServService> MSService; CommandCSLog commandcslog; - ExtensibleItem<LogSettingsImpl> logsettings; Serialize::Type logsetting_type; + ExtensibleItem<LogSettingsImpl> logsettings; struct LogDefault { @@ -289,8 +289,9 @@ class CSLog : public Module public: CSLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - MSService("MemoServService", "MemoServ"), commandcslog(this), logsettings(this, "logsettings"), - logsetting_type("LogSetting", LogSettingImpl::Unserialize) + MSService("MemoServService", "MemoServ"), commandcslog(this), + logsetting_type("LogSetting", LogSettingImpl::Unserialize), + logsettings(this, "logsettings") { } diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index f5c98d487..b0a2e2b91 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -42,6 +42,16 @@ struct ModeLocksImpl : ModeLocks { } + ~ModeLocksImpl() + { + for (ModeList::iterator it = this->mlocks->begin(); it != this->mlocks->end();) + { + ModeLock *ml = *it; + ++it; + delete ml; + } + } + bool HasMLock(ChannelMode *mode, const Anope::string ¶m, bool status) const anope_override { if (!mode) @@ -818,13 +828,14 @@ class CSMode : public Module { CommandCSMode commandcsmode; CommandCSModes commandcsmodes; - ExtensibleItem<ModeLocksImpl> modelocks; Serialize::Type modelocks_type; + ExtensibleItem<ModeLocksImpl> modelocks; public: CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsmode(this), commandcsmodes(this), - modelocks(this, "modelocks"), modelocks_type("ModeLock", ModeLockImpl::Unserialize) + modelocks_type("ModeLock", ModeLockImpl::Unserialize), + modelocks(this, "modelocks") { } diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index 79d7fdf4a..9fa75eea8 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -27,6 +27,17 @@ struct AJoinEntry : Serializable AJoinEntry(Extensible *) : Serializable("AJoinEntry") { } + ~AJoinEntry() + { + AJoinList *channels = owner->GetExt<AJoinList>("ajoinlist"); + if (channels) + { + std::vector<AJoinEntry *>::iterator it = std::find((*channels)->begin(), (*channels)->end(), this); + if (it != (*channels)->end()) + (*channels)->erase(it); + } + } + void Serialize(Serialize::Data &sd) const anope_override { if (!this->owner) @@ -147,7 +158,6 @@ class CommandNSAJoin : public Command else { delete (*channels)->at(i); - (*channels)->erase((*channels)->begin() + i); source.Reply(_("%s was removed from %s's auto join list."), chan.c_str(), nc->display.c_str()); } @@ -214,13 +224,14 @@ class CommandNSAJoin : public Command class NSAJoin : public Module { - Serialize::Type ajoinentry_type; CommandNSAJoin commandnsajoin; + Serialize::Type ajoinentry_type; ExtensibleItem<AJoinList> ajoinlist; public: NSAJoin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize), commandnsajoin(this), ajoinlist(this, "ajoinlist") + commandnsajoin(this), + ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize), ajoinlist(this, "ajoinlist") { if (!IRCD->CanSVSJoin) |