diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-03 01:52:59 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-03 01:52:59 +0000 |
commit | de25d946733f774e3a5b53a58438a9c92af0acbe (patch) | |
tree | 459ccc3b0c2423f1592afec4b458615968a1176d /include | |
parent | e57ed15735a3f23d6451845c7cf96758e6909d8c (diff) |
Get rid of a bunch of memory-wasting C-style strings
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11796 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r-- | include/channels.h | 6 | ||||
-rw-r--r-- | include/configreader.h | 68 | ||||
-rw-r--r-- | include/dns.h | 23 | ||||
-rw-r--r-- | include/inspircd.h | 22 | ||||
-rw-r--r-- | include/socket.h | 4 | ||||
-rw-r--r-- | include/typedefs.h | 4 | ||||
-rw-r--r-- | include/u_listmode.h | 2 |
7 files changed, 37 insertions, 92 deletions
diff --git a/include/channels.h b/include/channels.h index ec09cbbca..1ded25a73 100644 --- a/include/channels.h +++ b/include/channels.h @@ -241,7 +241,7 @@ class CoreExport Channel : public Extensible * @return The number of users left on the channel. If this is zero * when the method returns, you MUST delete the Channel immediately! */ - long ServerKickUser(User* user, const char* reason, const char* servername = NULL); + long ServerKickUser(User* user, const char* reason, const std::string& servername = ""); /** Part a user from this channel with the given reason. * If the reason field is NULL, no reason will be sent. @@ -281,13 +281,13 @@ class CoreExport Channel : public Extensible * @param text A printf-style format string which builds the output line without prefix * @param ... Zero or more POD type */ - void WriteChannelWithServ(const char* ServName, const char* text, ...) CUSTOM_PRINTF(3, 4); + void WriteChannelWithServ(const std::string& ServName, const char* text, ...) CUSTOM_PRINTF(3, 4); /** Write to a channel, from a server, using std::string for text * @param ServName Server name to prefix the line with * @param text A std::string containing the output line without prefix */ - void WriteChannelWithServ(const char* ServName, const std::string &text); + void WriteChannelWithServ(const std::string& ServName, const std::string &text); /** Write to all users on a channel except a specific user, using va_args for text. * Internally, this calls WriteAllExcept(). diff --git a/include/configreader.h b/include/configreader.h index 28138edd6..893259b7c 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -206,98 +206,98 @@ class CoreExport ServerConfig : public classbase /** Both for set(g|u)id. */ - char SetUser[MAXBUF]; - char SetGroup[MAXBUF]; + std::string SetUser; + std::string SetGroup; /** Holds the server name of the local server * as defined by the administrator. */ - char ServerName[MAXBUF]; + std::string ServerName; /** Notice to give to users when they are Xlined */ - char MoronBanner[MAXBUF]; + std::string MoronBanner; /* Holds the network name the local server * belongs to. This is an arbitary field defined * by the administrator. */ - char Network[MAXBUF]; + std::string Network; /** Holds the description of the local server * as defined by the administrator. */ - char ServerDesc[MAXBUF]; + std::string ServerDesc; /** Holds the admin's name, for output in * the /ADMIN command. */ - char AdminName[MAXBUF]; + std::string AdminName; /** Holds the email address of the admin, * for output in the /ADMIN command. */ - char AdminEmail[MAXBUF]; + std::string AdminEmail; /** Holds the admin's nickname, for output * in the /ADMIN command */ - char AdminNick[MAXBUF]; + std::string AdminNick; /** The admin-configured /DIE password */ - char diepass[MAXBUF]; + std::string diepass; /** The admin-configured /RESTART password */ - char restartpass[MAXBUF]; + std::string restartpass; /** The hash method for *BOTH* the die and restart passwords. */ - char powerhash[MAXBUF]; + std::string powerhash; /** The pathname and filename of the message of the * day file, as defined by the administrator. */ - char motd[MAXBUF]; + std::string motd; /** The pathname and filename of the rules file, * as defined by the administrator. */ - char rules[MAXBUF]; + std::string rules; /** The quit prefix in use, or an empty string */ - char PrefixQuit[MAXBUF]; + std::string PrefixQuit; /** The quit suffix in use, or an empty string */ - char SuffixQuit[MAXBUF]; + std::string SuffixQuit; /** The fixed quit message in use, or an empty string */ - char FixedQuit[MAXBUF]; + std::string FixedQuit; /** The part prefix in use, or an empty string */ - char PrefixPart[MAXBUF]; + std::string PrefixPart; /** The part suffix in use, or an empty string */ - char SuffixPart[MAXBUF]; + std::string SuffixPart; /** The fixed part message in use, or an empty string */ - char FixedPart[MAXBUF]; + std::string FixedPart; /** The last string found within a <die> tag, or * an empty string. */ - char DieValue[MAXBUF]; + std::string DieValue; /** The DNS server to use for DNS queries */ - char DNSServer[MAXBUF]; + std::string DNSServer; /** Pretend disabled commands don't exist. */ @@ -307,7 +307,7 @@ class CoreExport ServerConfig : public classbase * of commands which are disabled by the * administrator of the server for non-opers. */ - char DisabledCommands[MAXBUF]; + std::string DisabledCommands; /** This variable identifies which usermodes have been diabled. */ @@ -451,11 +451,11 @@ class CoreExport ServerConfig : public classbase /** Set to a non-empty string to obfuscate the server name of users in WHOIS */ - char HideWhoisServer[MAXBUF]; + std::string HideWhoisServer; /** Set to a non empty string to obfuscate nicknames prepended to a KILL. */ - char HideKillsServer[MAXBUF]; + std::string HideKillsServer; /** The MOTD file, cached in a file_cache type. */ @@ -487,7 +487,7 @@ class CoreExport ServerConfig : public classbase /** STATS characters in this list are available * only to operators. */ - char UserStats[MAXBUF]; + std::string UserStats; /** The path and filename of the ircd.log file */ @@ -495,11 +495,11 @@ class CoreExport ServerConfig : public classbase /** Default channel modes */ - char DefaultModes[MAXBUF]; + std::string DefaultModes; /** Custom version string, which if defined can replace the system info in VERSION. */ - char CustomVersion[MAXBUF]; + std::string CustomVersion; /** List of u-lined servers */ @@ -565,7 +565,7 @@ class CoreExport ServerConfig : public classbase * makes code simpler. 0AA, 1BB etc with letters are reserved * for services use. */ - char sid[MAXBUF]; + std::string sid; /** True if we have been told to run the testsuite from the commandline, * rather than entering the mainloop. @@ -679,7 +679,7 @@ class CoreExport ServerConfig : public classbase */ int ConfVarEnum(const std::string &tag, int index); - bool ApplyDisabledCommands(const char* data); + bool ApplyDisabledCommands(const std::string& data); /** Returns the fully qualified path to the inspircd directory * @return The full program directory @@ -795,9 +795,6 @@ template<typename T> class ValueContainer : public ValueContainerBase void Set(ServerConfig* conf, const ValueItem& item); }; -template<> void ValueContainer<char[MAXBUF]>::Set(ServerConfig* conf, ValueItem const& item); - - class ValueContainerLimit : public ValueContainerBase { size_t ServerLimits::* const vptr; @@ -826,11 +823,6 @@ typedef ValueContainer<unsigned int> ValueContainerUInt; /** A specialization of ValueContainer to hold a pointer to * a char array. */ -typedef ValueContainer<char[MAXBUF]> ValueContainerChar; - -/** A specialization of ValueContainer to hold a pointer to - * a char array. - */ typedef ValueContainer<std::string> ValueContainerString; /** A specialization of ValueContainer to hold a pointer to diff --git a/include/dns.h b/include/dns.h index 1bce4f11a..76a69b6e4 100644 --- a/include/dns.h +++ b/include/dns.h @@ -320,14 +320,6 @@ class CoreExport DNS : public EventHandler int currid; /** - * We have to turn off a few checks on received packets - * when people are using 4in6 (e.g. ::ffff:xxxx). This is - * a temporary kludge, Please let me know if you know how - * to fix it. - */ - bool ip6munge; - - /** * Currently cached items */ dnscache* cache; @@ -344,20 +336,7 @@ class CoreExport DNS : public EventHandler public: - /** - * Server address being used currently - */ - int socketfamily; - - /** - * IPV6 server address - */ - in6_addr myserver6; - - /** - * IPV4 server address - */ - in_addr myserver4; + irc::sockets::sockaddrs myserver; /** * Currently active Resolver classes diff --git a/include/inspircd.h b/include/inspircd.h index f240c2ecb..b7827f315 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -421,10 +421,6 @@ class CoreExport InspIRCd : public classbase */ void BuildISupport(); - /** List of server names we've seen. - */ - servernamelist servernames; - /** Time this ircd was booted */ time_t startup_time; @@ -532,24 +528,6 @@ class CoreExport InspIRCd : public classbase */ bool BindSocket(int sockfd, int port, const char* addr, bool dolisten = true); - /** Adds a server name to the list of servers we've seen - * @param The servername to add - */ - void AddServerName(const std::string &servername); - - /** Finds a cached char* pointer of a server name, - * This is used to optimize User by storing only the pointer to the name - * @param The servername to find - * @return A pointer to this name, gauranteed to never become invalid - */ - const char* FindServerNamePtr(const std::string &servername); - - /** Returns true if we've seen the given server name before - * @param The servername to find - * @return True if we've seen this server name before - */ - bool FindServerName(const std::string &servername); - /** Gets the GECOS (description) field of the given server. * If the servername is not that of the local server, the name * is passed to handling modules which will attempt to determine diff --git a/include/socket.h b/include/socket.h index 6e4bf9dbd..2941606a3 100644 --- a/include/socket.h +++ b/include/socket.h @@ -96,7 +96,7 @@ namespace irc * or a negative value upon failure (negative values are invalid file * descriptors) */ - CoreExport int OpenTCPSocket(const char* addr, int socktype = SOCK_STREAM); + CoreExport int OpenTCPSocket(const std::string& addr, int socktype = SOCK_STREAM); /** Return the size of the structure for syscall passing */ CoreExport int sa_size(const irc::sockets::sockaddrs& sa); @@ -107,7 +107,7 @@ namespace irc * @param sa The structure to place the result in. Will be zeroed prior to conversion * @return true if the conversion was successful, false if not. */ - CoreExport bool aptosa(const char* addr, int port, irc::sockets::sockaddrs* sa); + CoreExport bool aptosa(const std::string& addr, int port, irc::sockets::sockaddrs* sa); /** Convert a binary sockaddr to an address-port pair * @param sa The structure to convert * @param addr the IP address diff --git a/include/typedefs.h b/include/typedefs.h index a40e6cfc2..fa4477f84 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -27,10 +27,6 @@ #endif #endif -/** Server name cache - */ -typedef std::vector<std::string*> servernamelist; - /** A cached text file stored line by line. */ typedef std::deque<std::string> file_cache; diff --git a/include/u_listmode.h b/include/u_listmode.h index cb211c9be..7c34605f4 100644 --- a/include/u_listmode.h +++ b/include/u_listmode.h @@ -180,7 +180,7 @@ class ListModeBase : public ModeHandler { for (modelist::reverse_iterator it = el->rbegin(); it != el->rend(); ++it) { - user->WriteNumeric(listnumeric, "%s %s %s %s %s", user->nick.c_str(), channel->name.c_str(), it->mask.c_str(), (it->nick.length() ? it->nick.c_str() : ServerInstance->Config->ServerName), it->time.c_str()); + user->WriteNumeric(listnumeric, "%s %s %s %s %s", user->nick.c_str(), channel->name.c_str(), it->mask.c_str(), (it->nick.length() ? it->nick.c_str() : ServerInstance->Config->ServerName.c_str()), it->time.c_str()); } } user->WriteNumeric(endoflistnumeric, "%s %s :%s", user->nick.c_str(), channel->name.c_str(), endofliststring.c_str()); |