]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_silence.cpp
Allocate id properly
[user/henk/code/inspircd.git] / src / modules / m_silence.cpp
index 4beda442365f63230d11b5cb5bb201d7d32923b3..39b810dfe07bbc15187e7b8f687990dbdbba56ce 100644 (file)
@@ -36,18 +36,19 @@ typedef std::vector<std::string> silencelist;
 class cmd_silence : public command_t
 {
  public:
-       cmd_silence() : command_t("SILENCE", 0, 1)
+       cmd_silence() : command_t("SILENCE", 0, 0)
        {
                this->source = "m_silence.so";
        }
 
-       void Handle (char **parameters, int pcnt, userrec *user)
+       void Handle (const char** parameters, int pcnt, userrec *user)
        {
                if (!pcnt)
                {
                        // no parameters, show the current silence list.
                        // Use Extensible::GetExt to fetch the silence list
-                       silencelist* sl = (silencelist*)user->GetExt("silence_list");
+                       silencelist* sl;
+                       user->GetExt("silence_list", sl);
                        // if the user has a silence list associated with their user record, show it
                        if (sl)
                        {
@@ -61,13 +62,14 @@ class cmd_silence : public command_t
                else if (pcnt > 0)
                {
                        // one or more parameters, add or delete entry from the list (only the first parameter is used)
-                       char *nick = parameters[0];
+                       const char *nick = parameters[0];
                        if (nick[0] == '-')
                        {
                                // removing an item from the list
                                nick++;
                                // fetch their silence list
-                               silencelist* sl = (silencelist*)user->GetExt("silence_list");
+                               silencelist* sl;
+                               user->GetExt("silence_list", sl);
                                // does it contain any entries and does it exist?
                                if (sl)
                                {
@@ -91,7 +93,7 @@ class cmd_silence : public command_t
                                        {
                                                // tidy up -- if a user's list is empty, theres no use having it
                                                // hanging around in the user record.
-                                               delete sl;
+                                               DELETE(sl);
                                                user->Shrink("silence_list");
                                        }
                                }
@@ -100,12 +102,13 @@ class cmd_silence : public command_t
                        {
                                nick++;
                                // fetch the user's current silence list
-                               silencelist* sl = (silencelist*)user->GetExt("silence_list");
+                               silencelist* sl;
+                               user->GetExt("silence_list", sl);
                                // what, they dont have one??? WE'RE ALL GONNA DIE! ...no, we just create an empty one.
                                if (!sl)
                                {
                                        sl = new silencelist;
-                                       user->Extend(std::string("silence_list"),(char*)sl);
+                                       user->Extend(std::string("silence_list"), sl);
                                }
                                // add the nick to it -- silence only takes nicks for some reason even though its list shows masks
                                for (silencelist::iterator n = sl->begin(); n != sl->end();  n++)
@@ -150,10 +153,11 @@ class ModuleSilence : public Module
        {
                // when the user quits tidy up any silence list they might have just to keep things tidy
                // and to prevent a HONKING BIG MEMORY LEAK!
-               silencelist* sl = (silencelist*)user->GetExt("silence_list");
+               silencelist* sl;
+               user->GetExt("silence_list", sl);
                if (sl)
                {
-                       delete sl;
+                       DELETE(sl);
                        user->Shrink("silence_list");
                }
        }
@@ -173,7 +177,8 @@ class ModuleSilence : public Module
                if (target_type == TYPE_USER)
                {
                        userrec* u = (userrec*)dest;
-                       silencelist* sl = (silencelist*)u->GetExt("silence_list");
+                       silencelist* sl;
+                       u->GetExt("silence_list", sl);
                        if (sl)
                        {
                                for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)