]> jfr.im git - irc/quakenet/newserv.git/blobdiff - nick/nickalloc.c
Make valgrind a bit happier.
[irc/quakenet/newserv.git] / nick / nickalloc.c
index 395aec0a751a19a063a5582a579ce4df753465f6..7425f31f1d579e80f4d8d019d3dab3d27ec1151c 100644 (file)
@@ -1,6 +1,8 @@
 /* nick/host/realname/authname allocator */
 
 #include "nick.h"
+#include "../core/nsmalloc.h"
+
 #include <assert.h>
 #include <stdlib.h>
 
 
 nick *freenicks;
 host *freehosts;
-authname *freeauthnames;
 
 void initnickalloc() {
   freenicks=NULL;
   freehosts=NULL;
-  freeauthnames=NULL;
   
   assert(sizeof(host)==sizeof(realname));
 }
@@ -34,7 +34,7 @@ nick *newnick() {
   int i;
   
   if (freenicks==NULL) {
-    freenicks=(nick *)malloc(ALLOCUNIT*sizeof(nick));
+    freenicks=(nick *)nsmalloc(POOL_NICK,ALLOCUNIT*sizeof(nick));
     for (i=0;i<(ALLOCUNIT-1);i++) {
       freenicks[i].next=&(freenicks[i+1]);
     }
@@ -57,7 +57,7 @@ host *newhost() {
   int i;
   
   if (freehosts==NULL) {
-    freehosts=(host *)malloc(ALLOCUNIT*sizeof(host));
+    freehosts=(host *)nsmalloc(POOL_NICK,ALLOCUNIT*sizeof(host));
     for (i=0;i<(ALLOCUNIT-1);i++) {
       freehosts[i].next=&(freehosts[i+1]);
     }
@@ -75,25 +75,3 @@ void freehost (host *hp) {
   freehosts=hp;
 }
 
-authname *newauthname() {
-  authname *anp;
-  int i;
-  
-  if (freeauthnames==NULL) {
-    freeauthnames=(authname *)malloc(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;
-}
-
-void freeauthname (authname *anp) {
-  anp->next=freeauthnames;
-  freeauthnames=anp;
-}