]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanindex/chanindex.c
GLINES: fix null pointer deref in trustgline / trustungline
[irc/quakenet/newserv.git] / chanindex / chanindex.c
index a859250cb2b86eda681180725762db20427f6ce9..2aa763ea666bbcbd4c41a34b2b4d4d73d5ffe986 100644 (file)
@@ -5,17 +5,17 @@
 #include "../lib/irc_string.h"
 #include "../core/error.h"
 #include "../core/nsmalloc.h"
+#include "../lib/version.h"
 
 #include <stdio.h>
 #include <string.h>
 
-#define ALLOCUNIT      1000
+MODULE_VERSION("")
 
-#define channelhash(x)  (crc32i(x)%CHANNELHASHSIZE)
+#define channelhash(x)  (irc_crc32i(x)%CHANNELHASHSIZE)
 
 chanindex *chantable[CHANNELHASHSIZE];
 sstring *extnames[MAXCHANNELEXTS];
-chanindex *freechanindices;
 
 unsigned int channelmarker;
 
@@ -23,7 +23,6 @@ void _init() {
   memset(chantable,0,sizeof(chantable));
   memset(extnames,0,sizeof(extnames));
   channelmarker=0;
-  freechanindices=NULL;
 }
 
 void _fini() {
@@ -31,26 +30,11 @@ void _fini() {
 }
 
 chanindex *getchanindex() {
-  int i;
-  chanindex *cip;
-
-  if (freechanindices==NULL) {
-    freechanindices=(chanindex *)nsmalloc(POOL_CHANINDEX, ALLOCUNIT*sizeof(chanindex));
-    for(i=0;i<ALLOCUNIT-1;i++) {
-      freechanindices[i].next=&(freechanindices[i+1]);
-    }
-    freechanindices[ALLOCUNIT-1].next=NULL;
-  }
-
-  cip=freechanindices;
-  freechanindices=cip->next;
-
-  return cip;
+  return nsmalloc(POOL_CHANINDEX, sizeof(chanindex));
 }
 
 void freechanindex(chanindex *cip) {
-  cip->next=freechanindices;
-  freechanindices=cip;
+  nsfree(POOL_CHANINDEX, cip);
 }
 
 chanindex *findchanindex(const char *name) {