summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-22 17:18:18 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-22 17:18:18 +0000
commit4ffd644a14fa40b758f8937b06844861009bfec1 (patch)
tree53f79a6d5efa581098363f6631d6f7170061bb93
parent11e0cbf4dd4356c2791ab04fcec76b58bd44567e (diff)
Optimized out strcpys that copy empty strings (craq++)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2637 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/channels.cpp2
-rw-r--r--src/cmd_modules.cpp2
-rw-r--r--src/cmd_who.cpp16
-rw-r--r--src/command_parse.cpp8
-rw-r--r--src/dnsqueue.cpp4
-rw-r--r--src/inspircd_io.cpp6
-rw-r--r--src/mode.cpp11
-rw-r--r--src/modules/m_cloaking.cpp2
-rw-r--r--src/modules/m_opermd5.cpp2
-rw-r--r--src/users.cpp5
10 files changed, 29 insertions, 29 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index fee297ec8..0201ec7b4 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -217,7 +217,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
strlcpy(chanlist[cname]->name, cname,CHANMAX);
chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL;
chanlist[cname]->created = TIME;
- strcpy(chanlist[cname]->topic, "");
+ *chanlist[cname]->topic = 0;
strncpy(chanlist[cname]->setby, user->nick,NICKMAX);
chanlist[cname]->topicset = 0;
Ptr = chanlist[cname];
diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp
index 5d8625576..bdff5c7f8 100644
--- a/src/cmd_modules.cpp
+++ b/src/cmd_modules.cpp
@@ -69,7 +69,7 @@ void cmd_modules::Handle (char **parameters, int pcnt, userrec *user)
Version V = modules[i]->GetVersion();
char modulename[MAXBUF];
char flagstate[MAXBUF];
- strcpy(flagstate,"");
+ *flagstate = 0;
if (V.Flags & VF_STATIC)
strlcat(flagstate,", static",MAXBUF);
if (V.Flags & VF_VENDOR)
diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp
index 9c74b29eb..bc3c090dd 100644
--- a/src/cmd_who.cpp
+++ b/src/cmd_who.cpp
@@ -82,8 +82,8 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
if ((!common_channels(user,i->second)) && (isnick(i->second->nick)))
{
// Bug Fix #29
- strcpy(tmp, "");
- if (strcmp(i->second->awaymsg, "")) {
+ *tmp = 0;
+ if (*i->second->awaymsg) {
strlcat(tmp, "G", 9);
} else {
strlcat(tmp, "H", 9);
@@ -120,8 +120,8 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
if ((has_channel(i->second,Ptr)) && (isnick(i->second->nick)))
{
// Fix Bug #29 - Part 2..
- strcpy(tmp, "");
- if (strcmp(i->second->awaymsg, "")) {
+ *tmp = 0;
+ if (*i->second->awaymsg) {
strlcat(tmp, "G", 9);
} else {
strlcat(tmp, "H", 9);
@@ -151,8 +151,8 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
if (u)
{
// Bug Fix #29 -- Part 29..
- strcpy(tmp, "");
- if (strcmp(u->awaymsg, "")) {
+ *tmp = 0;
+ if (*u->awaymsg) {
strlcat(tmp, "G" ,9);
} else {
strlcat(tmp, "H" ,9);
@@ -173,8 +173,8 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
// If i were a rich man.. I wouldn't need to me making these bugfixes..
// But i'm a poor bastard with nothing better to do.
userrec* oper = *i;
- strcpy(tmp, "");
- if (strcmp(oper->awaymsg, "")) {
+ *tmp = 0;
+ if (*oper->awaymsg) {
strlcat(tmp, "G" ,9);
} else {
strlcat(tmp, "H" ,9);
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 1f17e4735..ff25ec878 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -114,12 +114,12 @@ int CommandParser::LoopCall(command_t* fn, char **parameters, int pcnt, userrec
char moo[MAXBUF];
for (int i = 0; i <32; i++)
- strcpy(blog[i],"");
+ *blog[i] = 0;
for (int i = 0; i <32; i++)
- strcpy(blog2[i],"");
+ *blog2[i] = 0;
- strcpy(moo,"");
+ *moo = 0;
for (int i = 0; i <10; i++)
{
if (!parameters[i])
@@ -143,7 +143,7 @@ int CommandParser::LoopCall(command_t* fn, char **parameters, int pcnt, userrec
{
return 0;
}
- strcpy(plist,"");
+ *plist = 0;
for (int i = start; i <= end; i++)
{
if (parameters[i])
diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp
index eb3160ec4..3b6bd2103 100644
--- a/src/dnsqueue.cpp
+++ b/src/dnsqueue.cpp
@@ -68,12 +68,12 @@ private:
public:
Lookup()
{
- strcpy(u,"");
+ *u = 0;
}
void Reset()
{
- strcpy(u,"");
+ *u = 0;
}
~Lookup()
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 1308a8dc9..b0170d0a3 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -936,7 +936,7 @@ int ServerConfig::ReadConf(std::stringstream *config, const char* tag, const cha
if (!key)
{
/* value not found in tag */
- strcpy(result,"");
+ *result = 0;
return 0;
}
else
@@ -947,7 +947,7 @@ int ServerConfig::ReadConf(std::stringstream *config, const char* tag, const cha
if (!*key)
{
/* missing quote */
- strcpy(result,"");
+ *result = 0;
return 0;
}
key++;
@@ -985,7 +985,7 @@ int ServerConfig::ReadConf(std::stringstream *config, const char* tag, const cha
}
}
}
- strcpy(result,""); // value or its tag not found at all
+ *result = 0; // value or its tag not found at all
return 0;
}
diff --git a/src/mode.cpp b/src/mode.cpp
index 7d401d7e3..de994dd5b 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -1289,7 +1289,8 @@ void cmd_mode::Handle (char **parameters, int pcnt, userrec *user)
return;
}
- strcpy(outpars,"+");
+ outpars[0] = '+';
+ outpars[1] = 0;
direction = 1;
if ((parameters[1][0] != '+') && (parameters[1][0] != '-'))
@@ -1383,7 +1384,7 @@ void cmd_mode::Handle (char **parameters, int pcnt, userrec *user)
outpars[r+1]='\0';
outpars[r] = parameters[1][i];
- strcpy(temp,"");
+ *temp = 0;
for (q = 0; q < strlen(dmodes); q++)
{
if (dmodes[q] != parameters[1][i])
@@ -1555,7 +1556,8 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user)
char dmodes[MAXBUF];
strlcpy(dmodes,dest->modes,52);
- strcpy(outpars,"+");
+ outpars[0] = '+';
+ outpars[1] = 0;
direction = 1;
if ((parameters[1][0] != '+') && (parameters[1][0] != '-'))
@@ -1639,8 +1641,7 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user)
unsigned int v1 = strlen(outpars);
outpars[v1+1]='\0';
outpars[v1] = parameters[1][i];
-
- strcpy(temp,"");
+ *temp = 0;
for (q = 0; q < strlen(dmodes); q++)
{
if (dmodes[q] != parameters[1][i])
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index 7bcfb0af2..20d60ebef 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -256,7 +256,7 @@ class ModuleCloaking : public Module
int i = 0;
unsigned char bytes[16];
char hash[MAXBUF];
- strcpy(hash,"");
+ *hash = 0;
MyMD5((char*)bytes,src,strlen(src));
for (i = 0; i < 16; i++)
{
diff --git a/src/modules/m_opermd5.cpp b/src/modules/m_opermd5.cpp
index 44b029082..2c2b51404 100644
--- a/src/modules/m_opermd5.cpp
+++ b/src/modules/m_opermd5.cpp
@@ -245,7 +245,7 @@ void GenHash(const char* src, char* dest)
int i = 0;
unsigned char bytes[16];
char hash[1024];
- strcpy(hash,"");
+ *hash = 0;
MyMD5((char*)bytes,(void*)src,strlen(src));
for (i = 0; i < 16; i++)
{
diff --git a/src/users.cpp b/src/users.cpp
index 2993b31bb..6f5c96279 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -63,8 +63,7 @@ template<typename T> inline string ConvToStr(const T &in)
userrec::userrec()
{
// the PROPER way to do it, AVOID bzero at *ALL* costs
- *nick = *ident = *host = *dhost = *fullname = *modes = *awaymsg = *oper = 0;
- strcpy(ip,"127.0.0.1");
+ *nick = *ident = *host = *dhost = *fullname = *modes = *awaymsg = *oper = *ip = 0
server = (char*)FindServerNamePtr(Config->ServerName);
reset_due = TIME;
lines_in = fd = lastping = signon = idle_lastmsg = nping = registered = 0;
@@ -761,7 +760,7 @@ void force_nickchange(userrec* user,const char* newnick)
char nick[MAXBUF];
int MOD_RESULT = 0;
- strcpy(nick,"");
+ *nick = 0;
FOREACH_RESULT(OnUserPreNick(user,newnick));
if (MOD_RESULT) {