]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Remove strnewdup(), it is a good source of possible memory leaks
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 00:47:36 +0000 (00:47 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 00:47:36 +0000 (00:47 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11622 e03df62e-2008-0410-955e-edbf42e46eb7

include/configreader.h
include/inspstring.h
src/configreader.cpp
src/users.cpp

index e70a1478a05f8e7bb0ea97c82bdb1afd6779b416..c8cd13081d82c553a4c1b51f98ae7639bdfcbcf9 100644 (file)
@@ -46,19 +46,19 @@ struct operclass_data : public classbase
 {
        /** Command list for the class
         */
-       char *commandlist;
+       std::string commandlist;
 
        /** Channel mode list for the class
         */
-       char *cmodelist;
+       std::string cmodelist;
 
        /** User mode list for the class
         */
-       char *umodelist;
+       std::string umodelist;
 
        /** Priviledges given by this class
         */
-       char *privs;
+       std::string privs;
 };
 
 /** A Set of oper classes
index 54bb1c8bd641927e0546b67dfae7b293f134cb28..4a7fa627144fa36f0db090e637fe393f09d396c1 100644 (file)
@@ -39,19 +39,5 @@ CoreExport int charlcat(char* x,char y,int z);
  */
 CoreExport bool charremove(char* mp, char remove);
 
-/** strnewdup() is an implemenetation of strdup() which calls operator new
- * rather than malloc to allocate the new string, therefore allowing it to
- * be hooked into the C++ memory manager, and freed with operator delete.
- * This is required for windows, where we override operators new and delete
- * to allow for global allocation between modules and the core.
- */
-inline char * strnewdup(const char * s1)
-{
-       size_t len = strlen(s1) + 1;
-       char * p = new char[len];
-       memcpy(p, s1, len);
-       return p;
-}
-
 #endif
 
index 7babc7bb776dfcc6b2a577b27fe5ae4c67b6c581..eaea3f006567fecad841f691794b55d3e9185f83 100644 (file)
@@ -558,10 +558,10 @@ static bool DoClass(ServerConfig* conf, const char* tag, const char**, ValueList
                }
        }
 
-       conf->operclass[ClassName].commandlist = strnewdup(CommandList);
-       conf->operclass[ClassName].umodelist = strnewdup(UModeList);
-       conf->operclass[ClassName].cmodelist = strnewdup(CModeList);
-       conf->operclass[ClassName].privs = strnewdup(PrivsList);
+       conf->operclass[ClassName].commandlist = CommandList;
+       conf->operclass[ClassName].umodelist = UModeList;
+       conf->operclass[ClassName].cmodelist = CModeList;
+       conf->operclass[ClassName].privs = PrivsList;
        return true;
 }
 
index 921403f477fa03a00e5bd121bc51617d614cda6a..fdad68e2af3c74051b4b296a4ed0ec0402c4e60f 100644 (file)
@@ -787,7 +787,7 @@ void User::Oper(const std::string &opertype, const std::string &opername)
                                        this->AllowedPrivs->insert(mypriv);
                                }
 
-                               for (unsigned char* c = (unsigned char*)iter_operclass->second.umodelist; *c; ++c)
+                               for (unsigned char* c = (unsigned char*)iter_operclass->second.umodelist.c_str(); *c; ++c)
                                {
                                        if (*c == '*')
                                        {
@@ -799,7 +799,7 @@ void User::Oper(const std::string &opertype, const std::string &opername)
                                        }
                                }
 
-                               for (unsigned char* c = (unsigned char*)iter_operclass->second.cmodelist; *c; ++c)
+                               for (unsigned char* c = (unsigned char*)iter_operclass->second.cmodelist.c_str(); *c; ++c)
                                {
                                        if (*c == '*')
                                        {