diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-04-17 13:54:53 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-04-17 13:54:53 +0000 |
commit | 2dfc384cde46ba63ed7c2f4420712596096123ca (patch) | |
tree | 0427aad7d9f9c1655adb4022dc3c2c32ecb626d0 /src/modules | |
parent | c6f1e7997d846cabe33bb031d9d5fcf0790b83fa (diff) |
Fix SetModeParam to use std::string and handle edge cases.
Previously, changing the vaule of a mode could require 3 calls to SetMode and SetModeParam.
This also fixes memory leaks caused by the strdup() not always being paired with a free().
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11307 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_joinflood.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_kicknorejoin.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_nickflood.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 5 |
5 files changed, 14 insertions, 24 deletions
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index ae173bdb3..7e4a05d2b 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -144,8 +144,7 @@ class JoinFlood : public ModeHandler parameter = ConvToStr(njoins) + ":" +ConvToStr(nsecs); joinfloodsettings *f = new joinfloodsettings(ServerInstance, nsecs, njoins); channel->Extend("joinflood", f); - channel->SetMode('j', true); - channel->SetModeParam('j', parameter.c_str(), true); + channel->SetMode('j', parameter); return MODEACTION_ALLOW; } else @@ -168,8 +167,7 @@ class JoinFlood : public ModeHandler f = new joinfloodsettings(ServerInstance, nsecs, njoins); channel->Shrink("joinflood"); channel->Extend("joinflood", f); - channel->SetModeParam('j', cur_param.c_str(), false); - channel->SetModeParam('j', parameter.c_str(), true); + channel->SetMode('j', parameter); return MODEACTION_ALLOW; } else @@ -194,7 +192,7 @@ class JoinFlood : public ModeHandler channel->GetExt("joinflood", f); delete f; channel->Shrink("joinflood"); - channel->SetMode('j', false); + channel->SetMode('j', ""); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 527022c11..c5abc80c2 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -65,7 +65,7 @@ class KickRejoin : public ModeHandler } else { - channel->SetMode('J', false); + channel->SetMode('J', ""); return MODEACTION_ALLOW; } } @@ -74,8 +74,7 @@ class KickRejoin : public ModeHandler if (!channel->IsModeSet('J')) { parameter = ConvToStr(atoi(parameter.c_str())); - channel->SetModeParam('J', parameter.c_str(), adding); - channel->SetMode('J', adding); + channel->SetMode('J', parameter); return MODEACTION_ALLOW; } else @@ -90,11 +89,9 @@ class KickRejoin : public ModeHandler { // new mode param, replace old with new parameter = ConvToStr(atoi(parameter.c_str())); - cur_param = ConvToStr(atoi(cur_param.c_str())); if (parameter != "0") { - channel->SetModeParam('J', cur_param.c_str(), false); - channel->SetModeParam('J', parameter.c_str(), adding); + channel->SetMode('J', parameter); return MODEACTION_ALLOW; } else diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index ed40fca5b..f2082da33 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -143,8 +143,7 @@ class MsgFlood : public ModeHandler parameter = std::string(ban ? "*" : "") + ConvToStr(nlines) + ":" +ConvToStr(nsecs); floodsettings *fs = new floodsettings(ServerInstance,ban,nsecs,nlines); channel->Extend("flood",fs); - channel->SetMode('f', true); - channel->SetModeParam('f', parameter.c_str(), true); + channel->SetMode('f', parameter); return MODEACTION_ALLOW; } else @@ -164,8 +163,7 @@ class MsgFlood : public ModeHandler floodsettings *fs = new floodsettings(ServerInstance,ban,nsecs,nlines); channel->Shrink("flood"); channel->Extend("flood",fs); - channel->SetModeParam('f', cur_param.c_str(), false); - channel->SetModeParam('f', parameter.c_str(), true); + channel->SetMode('f', parameter); return MODEACTION_ALLOW; } else @@ -189,7 +187,7 @@ class MsgFlood : public ModeHandler { delete f; channel->Shrink("flood"); - channel->SetMode('f', false); + channel->SetMode('f', ""); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index f91694625..0a8e9a31d 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -144,8 +144,7 @@ class NickFlood : public ModeHandler parameter = ConvToStr(nnicks) + ":" +ConvToStr(nsecs); nickfloodsettings *f = new nickfloodsettings(ServerInstance, nsecs, nnicks); channel->Extend("nickflood", f); - channel->SetMode('F', true); - channel->SetModeParam('F', parameter.c_str(), true); + channel->SetMode('F', parameter); return MODEACTION_ALLOW; } else @@ -168,8 +167,7 @@ class NickFlood : public ModeHandler f = new nickfloodsettings(ServerInstance, nsecs, nnicks); channel->Shrink("nickflood"); channel->Extend("nickflood", f); - channel->SetModeParam('F', cur_param.c_str(), false); - channel->SetModeParam('F', parameter.c_str(), true); + channel->SetMode('F', parameter); return MODEACTION_ALLOW; } else @@ -194,7 +192,7 @@ class NickFlood : public ModeHandler channel->GetExt("nickflood", f); delete f; channel->Shrink("nickflood"); - channel->SetMode('F', false); + channel->SetMode('F', ""); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 9aa0dcf8b..00c191d26 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -68,15 +68,14 @@ class Redirect : public ModeHandler * We used to do some checking for circular +L here, but there is no real need for this any more especially as we * now catch +L looping in PreJoin. Remove it, since O(n) logic makes me sad, and we catch it anyway. :) -- w00t */ - channel->SetMode('L', true); - channel->SetModeParam('L', parameter.c_str(), true); + channel->SetMode('L', parameter); return MODEACTION_ALLOW; } else { if (channel->IsModeSet('L')) { - channel->SetMode('L', false); + channel->SetMode('L', ""); return MODEACTION_ALLOW; } } |