]> jfr.im git - irc/quakenet/newserv.git/blobdiff - authext/authext.c
Use nsmalloc/nsfree for authext.
[irc/quakenet/newserv.git] / authext / authext.c
index 0b395d764394b778106d678c99233856c4f2d0d1..11b1a58787176b8e2631da6408938edced5be56a 100644 (file)
@@ -6,16 +6,16 @@
 #include "../nick/nick.h"
 #include "../core/hooks.h"
 #include "../lib/strlfunc.h"
+#include "../lib/version.h"
 
 #include <string.h>
 #include <stdio.h>
 
-#define ALLOCUNIT 100
+MODULE_VERSION("")
 
 #define authnamehash(x)   ((x)%AUTHNAMEHASHSIZE)
 #define authnamehashbyname(x) (crc32i(x)%AUTHNAMEHASHSIZE)
 
-authname *freeauthnames;
 authname *authnametable[AUTHNAMEHASHSIZE];
 
 /* internal access only */
@@ -23,13 +23,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);
@@ -41,29 +40,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) {
@@ -74,7 +58,7 @@ int registerauthnameext(const char *name, int persistant) {
   for (i=0;i<MAXAUTHNAMEEXTS;i++) {
     if (authnameexts[i].name==NULL) {
       authnameexts[i].name=getsstring(name,100);
-      authnameexts[i].persistant=persistant;
+      authnameexts[i].persistent=persistent;
       return i;
     }
   }
@@ -173,7 +157,7 @@ void releaseauthname(authname *anp) {
     anp->nicks = NULL;
 
     for(i=0;i<MAXAUTHNAMEEXTS;i++)
-      if(authnameexts[i].persistant && anp->exts[i]!=NULL)
+      if(authnameexts[i].persistent && anp->exts[i]!=NULL)
         return;
 
     triggerhook(HOOK_AUTH_LOSTAUTHNAME, (void *)anp);