summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-23 21:12:36 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-23 21:12:36 +0000
commit20680f9c4964a5e10e3649a1e479078ff85c5c85 (patch)
tree9c49503f437ab3fac2d62a445f47aabd6040962e
parent029e804945f36111f5ca862c466d032dd38b5abf (diff)
This should save 128 bytes per user for non-opers. Well worth it imho for a reasonably large amount of unused ram.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9179 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/users.h4
-rw-r--r--src/users.cpp26
2 files changed, 28 insertions, 2 deletions
diff --git a/include/users.h b/include/users.h
index a12282ac9..07843b7c0 100644
--- a/include/users.h
+++ b/include/users.h
@@ -458,10 +458,10 @@ class CoreExport User : public connection
std::map<std::string, bool>* AllowedOperCommands;
/** Allowed user modes from oper classes. */
- bool AllowedUserModes[64];
+ bool* AllowedUserModes;
/** Allowed channel modes from oper classes. */
- bool AllowedChanModes[64];
+ bool* AllowedChanModes;
public:
/** Contains a pointer to the connect class a user is on from - this will be NULL for remote connections.
diff --git a/src/users.cpp b/src/users.cpp
index bdceba1f5..43ebfe0a3 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -193,6 +193,8 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
Visibility = NULL;
ip = NULL;
MyClass = NULL;
+ AllowedUserModes = NULL;
+ AllowedChanModes = NULL;
AllowedOperCommands = NULL;
memset(AllowedUserModes, 0, sizeof(AllowedUserModes));
memset(AllowedChanModes, 0, sizeof(AllowedChanModes));
@@ -231,6 +233,18 @@ User::~User()
AllowedOperCommands = NULL;
}
+ if (this->AllowedUserModes)
+ {
+ delete AllowedUserModes;
+ AllowedUserModes = NULL;
+ }
+
+ if (this->AllowedChanModes)
+ {
+ delete AllowedChanModes;
+ AllowedChanModes = NULL;
+ }
+
this->InvalidateCache();
this->DecrementModes();
@@ -447,6 +461,9 @@ bool User::HasModePermission(unsigned char mode, ModeType type)
if (!IS_OPER(this))
return false;
+ if (!AllowedUserModes || !AllowedChanModes)
+ return false;
+
return ((type == MODETYPE_USER ? AllowedUserModes : AllowedChanModes))[(mode - 'A')];
}
@@ -683,6 +700,15 @@ void User::Oper(const std::string &opertype, const std::string &opername)
else
AllowedOperCommands = new std::map<std::string, bool>;
+ if (!AllowedChanModes)
+ AllowedChanModes = new bool[64];
+
+ if (!AllowedUserModes)
+ AllowedUserModes = new bool[64];
+
+ memset(AllowedUserModes, 0, 64);
+ memset(AllowedChanModes, 0, 64);
+
char* Classes = strdup(iter_opertype->second);
char* myclass = strtok_r(Classes," ",&savept);
while (myclass)