diff options
| author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-12-20 18:39:52 +0000 |
|---|---|---|
| committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-12-20 18:39:52 +0000 |
| commit | 7a7f1f8390f68f84350de63ff330184999264fcc (patch) | |
| tree | 3990cde97ba0cd53db38114de9e4412b24930dd6 /src/core | |
| parent | 861fe9e7b32c8e1e523cc774547e460c9ed67289 (diff) | |
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
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/ns_resetpass.c | 51 |
1 files changed, 10 insertions, 41 deletions
diff --git a/src/core/ns_resetpass.c b/src/core/ns_resetpass.c index 81bbc2655..e8396398c 100644 --- a/src/core/ns_resetpass.c +++ b/src/core/ns_resetpass.c @@ -61,22 +61,11 @@ class CommandNSResetPass : public Command fprintf(mail->pipe, "\n.\n"); MailEnd(mail); - char *c; - time_t *t; - if (na->nc->GetExt("ns_resetpass_code", c)) - { - delete [] c; - na->nc->Shrink("ns_resetpass_code"); - } - if (na->nc->GetExt("ns_resetpass_time", t)) - { - delete t; - na->nc->Shrink("ns_resetpass_time"); - } + na->nc->Shrink("ns_resetpass_code"); + na->nc->Shrink("ns_resetpass_time"); - na->nc->Extend("ns_resetpass_code", sstrdup(passcode)); - t = new time_t(time(NULL)); - na->nc->Extend("ns_resetpass_time", t); + na->nc->Extend("ns_resetpass_code", new ExtensibleItemPointerArray<char>(sstrdup(passcode))); + na->nc->Extend("ns_resetpass_time", new ExtensibleItemRegular<time_t>(time(NULL))); alog("%s: %s!%s@%s used RESETPASS on %s (%s)", Config.s_NickServ, u->nick, u->GetIdent().c_str(), u->host, na->nick, na->nc->display); notice_lang(Config.s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick); @@ -111,8 +100,8 @@ class NSResetPass : public Module this->AddCommand(NICKSERV, new CommandNSResetPass()); - Implementation i[] = { I_OnNickServHelp, I_OnDelCore, I_OnPreCommand }; - ModuleManager::Attach(i, this, 3); + Implementation i[] = { I_OnNickServHelp, I_OnPreCommand }; + ModuleManager::Attach(i, this, 2); } void OnNickServHelp(User *u) @@ -120,37 +109,19 @@ class NSResetPass : public Module notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_RESETPASS); } - void OnDelCore(NickCore *nc) + EventReturn OnPreCommand(User *u, const std::string &service, const ci::string &command, const std::vector<ci::string> ¶ms) { + time_t t; char *c; - time_t *t; - if (nc->GetExt("ns_resetpass_code", c)) - { - delete [] c; - nc->Shrink("ns_resetpass_code"); - } - if (nc->GetExt("ns_resetpass_time", t)) - { - delete t; - nc->Shrink("ns_resetpass_time"); - } - } - - EventReturn OnPreCommand(User *u, const std::string &service, const ci::string &command, const std::vector<ci::string> ¶ms) - { if (service == Config.s_NickServ && command == "CONFIRM" && !params.empty()) { NickAlias *na = findnick(u->nick); - char *c; - time_t *t; - if (na && na->nc->GetExt("ns_resetpass_code", c) && na->nc->GetExt("ns_resetpass_time", t)) + if (na && na->nc->GetExtArray("ns_resetpass_code", c) && na->nc->GetExtRegular<time_t>("ns_resetpass_time", t)) { - if (*t < time(NULL) - 3600) + if (t < time(NULL) - 3600) { - delete [] c; - delete t; na->nc->Shrink("ns_resetpass_code"); na->nc->Shrink("ns_resetpass_time"); notice_lang(Config.s_NickServ, u, NICK_CONFIRM_EXPIRED); @@ -160,8 +131,6 @@ class NSResetPass : public Module std::string passcode = params[0].c_str(); if (passcode == c) { - delete [] c; - delete t; na->nc->Shrink("ns_resetpass_code"); na->nc->Shrink("ns_resetpass_time"); |
