]> jfr.im git - irc/quakenet/newserv.git/blobdiff - patricianick/patricianick.c
BUILD: add require-all build mode
[irc/quakenet/newserv.git] / patricianick / patricianick.c
index 529164221b79e5bc688f1f243f28a03335142848..44de41dcd4a63f45d2abf8cfdf71865940284e8f 100644 (file)
@@ -7,13 +7,13 @@
 #include "../core/nsmalloc.h"
 #include "../control/control.h"
 #include "../core/schedule.h"
+#include "../lib/version.h"
 
 #include <stdio.h>
 #include <string.h>
 
-#define ALLOCUNIT      100
+MODULE_VERSION("")
 
-patricianick_t *freepatricianicks;
 int pnode_ext;
 int pnick_ext;
 
@@ -65,19 +65,10 @@ void _fini() {
 }
 
 patricianick_t *getpatricianick() {
-  int i;
-  patricianick_t *pnp;
-
-  if (freepatricianicks==NULL) {
-    freepatricianicks=(patricianick_t *)nsmalloc(POOL_PATRICIANICK, ALLOCUNIT*sizeof(patricianick_t));
-    for(i=0;i<ALLOCUNIT-1;i++) {
-      freepatricianicks[i].identhash[0]=(nick *)&(freepatricianicks[i+1]);
-    }
-    freepatricianicks[ALLOCUNIT-1].identhash[0]=NULL;
-  }
+  patricianick_t *pnp = nsmalloc(POOL_PATRICIANICK, sizeof(patricianick_t));
 
-  pnp=freepatricianicks;
-  freepatricianicks=(patricianick_t *)pnp->identhash[0];
+  if (!pnp)
+    return NULL;
 
   memset(pnp, 0, sizeof(patricianick_t));
   return pnp;
@@ -86,6 +77,8 @@ patricianick_t *getpatricianick() {
 void addnicktonode(patricia_node_t *node, nick *np) {
   unsigned long hash;
 
+  patricia_ref_prefix(node->prefix);
+
   if (!(node->exts[pnode_ext])) {
     node->exts[pnode_ext] = getpatricianick();
   }
@@ -125,8 +118,7 @@ void deletenickfromnode(patricia_node_t *node, nick *np) {
 }
 
 void freepatricianick(patricianick_t *pnp) {
-  pnp->identhash[0]=(nick *)freepatricianicks;
-  freepatricianicks=pnp;
+  nsfree(POOL_PATRICIANICK, pnp);
 }
 
 void pn_hook_newuser(int hook, void *arg) {