summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-09 17:51:22 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-09 17:51:22 +0000
commit40d674d14cff051207e2004211b9e4e7686bb524 (patch)
tree25f8eea23504946c4caa7b30b5a2530b119b880a
parentd483a20dcb724d28777908c5da0505624729a840 (diff)
Fixes to way allocations are handled
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1346 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/channels.cpp4
-rw-r--r--src/dns.cpp2
-rw-r--r--src/dnsqueue.cpp4
-rw-r--r--src/inspircd.cpp18
-rw-r--r--src/inspircd_io.cpp2
-rw-r--r--src/mode.cpp7
-rw-r--r--src/modules.cpp2
7 files changed, 23 insertions, 16 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 0a6cdfdbb..6d6c15f13 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -192,11 +192,11 @@ std::string chanrec::GetModeParameter(char mode)
{
if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
{
- return std::string(i->parameter);
+ return i->parameter;
}
}
}
- return std::string("");
+ return "";
}
void chanrec::IncUserCounter()
diff --git a/src/dns.cpp b/src/dns.cpp
index a9039fcdc..bf6c16396 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -722,7 +722,7 @@ int DNS::GetFD()
std::string DNS::GetResult()
{
- result = dns_getresult(this->fd);
+ result = dns_getresult(this->fd);
if (result) {
statsDnsGood++;
dns_close(this->fd);
diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp
index 80189a95e..1e1aa33c8 100644
--- a/src/dnsqueue.cpp
+++ b/src/dnsqueue.cpp
@@ -193,8 +193,8 @@ public:
if (usr)
{
log(DEBUG,"New Lookup class for %s with DNSServer set to '%s'",nick.c_str(),DNSServer);
- resolver.SetNS(std::string(DNSServer));
- if (!resolver.ReverseLookup(std::string(usr->host)))
+ resolver.SetNS(DNSServer);
+ if (!resolver.ReverseLookup(usr->host))
return false;
strlcpy(u,nick.c_str(),NICKMAX);
return true;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index eaedeeb50..933c8d24e 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -2669,18 +2669,22 @@ long local_count()
void ShowMOTD(userrec *user)
{
+ char buf[65536];
std::string WholeMOTD = "";
if (!MOTD.size())
{
WriteServ(user->fd,"422 %s :Message of the day file is missing.",user->nick);
return;
}
- WholeMOTD = std::string(":") + std::string(ServerName) + std::string(" 375 ") + std::string(user->nick) + std::string(" :- ") + std::string(ServerName) + " message of the day\r\n";
+ snprintf(buf,65535,":%s 375 %s :- %s message of the day\r\n", ServerName, user->nick, ServerName);
+ WholeMOTD = WholeMOTD + buf;
for (int i = 0; i != MOTD.size(); i++)
{
- WholeMOTD = WholeMOTD + std::string(":") + std::string(ServerName) + std::string(" 372 ") + std::string(user->nick) + std::string(" :- ") + MOTD[i] + std::string("\r\n");
+ snprintf(buf,65535,":%s 372 %s :- %s\r\n", ServerName, user->nick, MOTD[i].c_str());
+ WholeMOTD = WholeMOTD + buf;
}
- WholeMOTD = WholeMOTD + std::string(":") + std::string(ServerName) + std::string(" 376 ") + std::string(user->nick) + std::string(" :End of message of the day.\r\n");
+ snprintf(buf,65535,":%s 376 %s :End of message of the day.\r\n", ServerName, user->nick);
+ WholeMOTD = WholeMOTD + buf;
// only one write operation
send(user->fd,WholeMOTD.c_str(),WholeMOTD.length(),0);
statsSent += WholeMOTD.length();
@@ -2755,7 +2759,7 @@ void FullConnectUser(userrec* user)
v << "MESHED WALLCHOPS MODES=13 CHANTYPES=# PREFIX=(ohv)@%+ MAP SAFELIST MAXCHANNELS=" << MAXCHANS;
v << " MAXBANS=60 NICKLEN=" << NICKMAX;
v << " TOPICLEN=307 KICKLEN=307 MAXTARGETS=20 AWAYLEN=307 CHANMODES=ohvb,k,l,psmnti NETWORK=";
- v << std::string(Network);
+ v << Network;
std::string data005 = v.str();
FOREACH_MOD On005Numeric(data005);
// anfl @ #ratbox, efnet reminded me that according to the RFC this cant contain more than 13 tokens per line...
@@ -3738,9 +3742,10 @@ void erase_module(int j)
bool UnloadModule(const char* filename)
{
+ std::string filename_str = filename;
for (int j = 0; j != module_names.size(); j++)
{
- if (module_names[j] == std::string(filename))
+ if (module_names[j] == filename_str)
{
if (modules[j]->GetVersion().Flags & VF_STATIC)
{
@@ -3830,6 +3835,7 @@ bool LoadModule(const char* filename)
{
char modfile[MAXBUF];
snprintf(modfile,MAXBUF,"%s/%s",ModPath,filename);
+ std::string filename_str = filename;
if (!DirValid(modfile))
{
log(DEFAULT,"Module %s is not within the modules directory.",modfile);
@@ -3841,7 +3847,7 @@ bool LoadModule(const char* filename)
{
for (int j = 0; j < module_names.size(); j++)
{
- if (module_names[j] == std::string(filename))
+ if (module_names[j] == filename_str)
{
log(DEFAULT,"Module %s is already loaded, cannot load a module twice!",modfile);
snprintf(MODERR,MAXBUF,"Module already loaded");
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 83c302d90..eb564e555 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -512,7 +512,7 @@ int ReadConf(std::stringstream *config, const char* tag, const char* var, int in
const char* buf = config->str().c_str();
long bptr = 0;
- long len = strlen(buf);
+ long len = config->str().length();
ptr = 0;
in_token = 0;
diff --git a/src/mode.cpp b/src/mode.cpp
index 87876141a..69284ab5c 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -552,12 +552,13 @@ std::string compress_modes(std::string modes,bool channelmodes)
static char v[2];
v[0] = (unsigned char)j;
v[1] = '\0';
- std::string::size_type pos = modes.find(std::string(v));
+ std::string mode_str = v;
+ std::string::size_type pos = modes.find(mode_str);
if (pos != std::string::npos)
{
log(DEBUG,"all occurances of mode %c to be deleted...",(unsigned char)j);
- while (modes.find(std::string(v)) != std::string::npos)
- modes.erase(modes.find(std::string(v)),1);
+ while (modes.find(mode_str) != std::string::npos)
+ modes.erase(modes.find(mode_str),1);
log(DEBUG,"New mode line: %s",modes.c_str());
}
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 495181cf4..006802cf5 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -889,7 +889,7 @@ std::string ConfigReader::ReadValue(std::string tag, std::string name, int index
this->error = CONF_VALUE_NOT_FOUND;
return "";
}
- return std::string(val);
+ return val;
}
bool ConfigReader::ReadFlag(std::string tag, std::string name, int index)