X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/b90b52aed59ca92b957c0c27b16f223f11671ec3..a4f1c6607af22469078a50c571218d6571914ca5:/authext/authext.c diff --git a/authext/authext.c b/authext/authext.c index e1939e38..7606832d 100644 --- a/authext/authext.c +++ b/authext/authext.c @@ -7,18 +7,19 @@ #include "../core/hooks.h" #include "../lib/strlfunc.h" #include "../lib/version.h" +#include "../lib/ccassert.h" #include #include MODULE_VERSION("") -#define ALLOCUNIT 100 +/* checking to see that u_int64_t == unsigned long long for strtoull */ +CCASSERT(sizeof(unsigned long long) == sizeof(u_int64_t)) #define authnamehash(x) ((x)%AUTHNAMEHASHSIZE) -#define authnamehashbyname(x) (crc32i(x)%AUTHNAMEHASHSIZE) +#define authnamehashbyname(x) (irc_crc32i(x)%AUTHNAMEHASHSIZE) -authname *freeauthnames; authname *authnametable[AUTHNAMEHASHSIZE]; /* internal access only */ @@ -26,13 +27,12 @@ static authname *authnametablebyname[AUTHNAMEHASHSIZE]; static struct { sstring *name; - int persistant; + int persistent; } authnameexts[MAXAUTHNAMEEXTS]; static void authextstats(int hooknum, void *arg); void _init(void) { - freeauthnames=NULL; memset(authnametable,0,sizeof(authnametable)); memset(authnametablebyname,0,sizeof(authnametablebyname)); registerhook(HOOK_CORE_STATSREQUEST, &authextstats); @@ -44,29 +44,14 @@ void _fini(void) { } authname *newauthname(void) { - authname *anp; - int i; - - if (freeauthnames==NULL) { - freeauthnames=(authname *)nsmalloc(POOL_AUTHEXT, ALLOCUNIT*sizeof(authname)); - for (i=0;i<(ALLOCUNIT-1);i++) { - freeauthnames[i].next=&(freeauthnames[i+1]); - } - freeauthnames[ALLOCUNIT-1].next=NULL; - } - - anp=freeauthnames; - freeauthnames=anp->next; - - return anp; + return nsmalloc(POOL_AUTHEXT, sizeof(authname)); } void freeauthname (authname *anp) { - anp->next=freeauthnames; - freeauthnames=anp; + nsfree(POOL_AUTHEXT, anp); } -int registerauthnameext(const char *name, int persistant) { +int registerauthnameext(const char *name, int persistent) { int i; if (findauthnameext(name)!=-1) { @@ -77,7 +62,7 @@ int registerauthnameext(const char *name, int persistant) { for (i=0;inicks = NULL; for(i=0;iexts[i]!=NULL) + if(authnameexts[i].persistent && anp->exts[i]!=NULL) return; triggerhook(HOOK_AUTH_LOSTAUTHNAME, (void *)anp);