summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-19 14:52:39 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-19 14:52:39 +0000
commita47ea856edfbd043d0295787fe7e1262fb8646a5 (patch)
tree8f5fc5789e7c3013bcfdbce699f74c6205fd991d /src/helperfuncs.cpp
parente0a8c7d7d2196ec0898ae5aee9e4123db88f9cb5 (diff)
Completely remove need for memset.
When we uniq_id++, we can wrap to 0 theoretically after 4 billion output messages, HOWEVER, when we do, 0 will be a valid comparison within the array :p git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4447 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 19ae22dc2..5a144cac8 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -51,7 +51,7 @@ extern InspIRCd* ServerInstance;
extern time_t TIME;
extern char lowermap[255];
extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-static int already_sent[MAX_DESCRIPTORS];
+static int already_sent[MAX_DESCRIPTORS] = {0};
extern std::vector<userrec*> all_opers;
extern user_hash clientlist;
extern chan_hash chanlist;
@@ -709,14 +709,8 @@ void WriteCommon(userrec *u, char* text, ...)
vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
- // XXX: Save on memset calls by only requiring memset every 4 billion or so
- // messages. This clever trick thought of during discussion with nazzy and w00t.
+ // XXX: Save on memset calls by using an ID. This clever trick thought of during discussion with nazzy and w00t.
uniq_id++;
- if (!uniq_id)
- {
- memset(&already_sent,0,MAX_DESCRIPTORS);
- uniq_id++;
- }
for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
{
@@ -764,11 +758,6 @@ void WriteCommon_NoFormat(userrec *u, const char* text)
// XXX: See comment in WriteCommon
uniq_id++;
- if (!uniq_id)
- {
- memset(&already_sent,0,MAX_DESCRIPTORS);
- uniq_id++;
- }
for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
{
@@ -869,11 +858,6 @@ void WriteCommonExcept(userrec *u, char* text, ...)
}
uniq_id++;
- if (!uniq_id)
- {
- memset(&already_sent,0,MAX_DESCRIPTORS);
- uniq_id++;
- }
for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
{
@@ -917,11 +901,6 @@ void WriteCommonExcept_NoFormat(userrec *u, const char* text)
}
uniq_id++;
- if (!uniq_id)
- {
- memset(&already_sent,0,MAX_DESCRIPTORS);
- uniq_id++;
- }
for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
{