From 7a7f1f8390f68f84350de63ff330184999264fcc Mon Sep 17 00:00:00 2001 From: Adam- Date: Sun, 20 Dec 2009 18:39:52 +0000 Subject: Rewrote part of extensible, it will now automatically unallocate memory for us so we don't have to manually delete it everywhere anymore git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2711 5417fbe8-f217-4b02-8779-1006273d7864 --- src/protocol/bahamut.c | 25 +++---------------------- src/protocol/inspircd11.c | 24 +++--------------------- src/protocol/ratbox.c | 24 +++--------------------- src/protocol/unreal32.c | 24 +++--------------------- 4 files changed, 12 insertions(+), 85 deletions(-) (limited to 'src/protocol') diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c index 6ec072b87..aee8b6f22 100644 --- a/src/protocol/bahamut.c +++ b/src/protocol/bahamut.c @@ -325,7 +325,7 @@ class BahamutIRCdProto : public IRCDProto void SetAutoIdentificationToken(User *u) { - char svidbuf[15], *c; + char svidbuf[15]; if (!u->nc) return; @@ -333,13 +333,8 @@ class BahamutIRCdProto : public IRCDProto srand(time(NULL)); snprintf(svidbuf, sizeof(svidbuf), "%d", rand()); - if (u->nc->GetExt("authenticationtoken", c)) - { - delete [] c; - u->nc->Shrink("authenticationtoken"); - } - - u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); + u->nc->Shrink("authenticationtoken"); + u->nc->Extend("authenticationtoken", new ExtensibleItemPointerArray(sstrdup(svidbuf))); BotInfo *bi = findbot(Config.s_NickServ); u->SetMode(bi, UMODE_REGISTERED); @@ -712,20 +707,6 @@ class ProtoBahamut : public Module moduleAddModes(); pmodule_ircd_proto(&ircd_proto); - moduleAddIRCDMsgs(); - - ModuleManager::Attach(I_OnDelCore, this); - } - - void OnDelCore(NickCore *nc) - { - char *c; - - if (nc->GetExt("authenticationtoken", c)) - { - delete [] c; - nc->Shrink("authenticationtoken"); - } } }; diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index 1eb6ba56e..cdeb58797 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -350,20 +350,15 @@ class InspIRCdProto : public IRCDProto void SetAutoIdentificationToken(User *u) { - char svidbuf[15], *c; + char svidbuf[15]; if (!u->nc) return; snprintf(svidbuf, sizeof(svidbuf), "%ld", static_cast(u->timestamp)); - if (u->nc->GetExt("authenticationtoken", c)) - { - delete [] c; - u->nc->Shrink("authenticationtoken"); - } - - u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); + u->nc->Shrink("authenticationtoken"); + u->nc->Extend("authenticationtoken", new ExtensibleItemPointerArray(sstrdup(svidbuf))); } } ircd_proto; @@ -1050,19 +1045,6 @@ class ProtoInspIRCd : public Module pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); - - ModuleManager::Attach(I_OnDelCore, this); - } - - void OnDelCore(NickCore *nc) - { - char *c; - - if (nc->GetExt("authenticationtoken", c)) - { - delete [] c; - nc->Shrink("authenticationtoken"); - } } }; diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index f10c86206..f10a4abcd 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -323,20 +323,15 @@ class RatboxProto : public IRCDTS6Proto void SetAutoIdentificationToken(User *u) { - char svidbuf[15], *c; + char svidbuf[15]; if (!u->nc) return; snprintf(svidbuf, sizeof(svidbuf), "%ld", static_cast(u->timestamp)); - if (u->nc->GetExt("authenticationtoken", c)) - { - delete [] c; - u->nc->Shrink("authenticationtoken"); - } - - u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); + u->nc->Shrink("authenticationtoken"); + u->nc->Extend("authenticationtoken", new ExtensibleItemPointerArray(svidbuf)); } } ircd_proto; @@ -852,8 +847,6 @@ class ProtoRatbox : public Module pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); - - ModuleManager::Attach(I_OnDelCore, this); } ~ProtoRatbox() @@ -861,17 +854,6 @@ class ProtoRatbox : public Module delete [] TS6SID; } - void OnDelCore(NickCore *nc) - { - char *c; - - if (nc->GetExt("authenticationtoken", c)) - { - delete [] c; - nc->Shrink("authenticationtoken"); - } - } - }; MODULE_INIT(ProtoRatbox) diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index 7dc55a452..085107e5c 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -449,7 +449,7 @@ class UnrealIRCdProto : public IRCDProto void SetAutoIdentificationToken(User *u) { - char svidbuf[15], *c; + char svidbuf[15]; if (!u->nc) return; @@ -457,13 +457,8 @@ class UnrealIRCdProto : public IRCDProto srand(time(NULL)); snprintf(svidbuf, sizeof(svidbuf), "%d", rand()); - if (u->nc->GetExt("authenticationtoken", c)) - { - delete [] c; - u->nc->Shrink("authenticationtoken"); - } - - u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); + u->nc->Shrink("authenticationtoken"); + u->nc->Extend("authenticationtoken", new ExtensibleItemPointerArray(sstrdup(svidbuf))); BotInfo *bi = findbot(Config.s_NickServ); u->SetMode(bi, UMODE_REGISTERED); @@ -1170,19 +1165,6 @@ class ProtoUnreal : public Module pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); - - ModuleManager::Attach(I_OnDelCore, this); - } - - void OnDelCore(NickCore *nc) - { - char *c; - - if (nc->GetExt("authenticationtoken", c)) - { - delete [] c; - nc->Shrink("authenticationtoken"); - } } }; -- cgit