]> jfr.im git - irc/quakenet/newserv.git/blobdiff - nick/nickalloc.c
CHANSERV: remove accidental sendemail from SETEMAIL command.
[irc/quakenet/newserv.git] / nick / nickalloc.c
index 7425f31f1d579e80f4d8d019d3dab3d27ec1151c..64a62b9d878623eb7e75870292554ab7e3cc97c7 100644 (file)
@@ -6,21 +6,9 @@
 #include <assert.h>
 #include <stdlib.h>
 
-#define ALLOCUNIT   100
-
 /* Hosts and realname structures are the same size */
 /* This assumption is checked in initnickalloc(); */
 
-nick *freenicks;
-host *freehosts;
-
-void initnickalloc() {
-  freenicks=NULL;
-  freehosts=NULL;
-  
-  assert(sizeof(host)==sizeof(realname));
-}
-
 realname *newrealname() {
   return (realname *)newhost();
 }
@@ -30,48 +18,18 @@ void freerealname(realname *rn) {
 }
 
 nick *newnick() {
-  nick *np;
-  int i;
-  
-  if (freenicks==NULL) {
-    freenicks=(nick *)nsmalloc(POOL_NICK,ALLOCUNIT*sizeof(nick));
-    for (i=0;i<(ALLOCUNIT-1);i++) {
-      freenicks[i].next=&(freenicks[i+1]);
-    }
-    freenicks[ALLOCUNIT-1].next=NULL;
-  }
-  
-  np=freenicks;
-  freenicks=np->next;
-  
-  return np;
+  return nsmalloc(POOL_NICK, sizeof(nick));
 } 
 
-void freenick (nick *np) {
-  np->next=freenicks;
-  freenicks=np;
+void freenick(nick *np) {
+  nsfree(POOL_NICK, np);
 }
 
 host *newhost() {
-  host *nh;
-  int i;
-  
-  if (freehosts==NULL) {
-    freehosts=(host *)nsmalloc(POOL_NICK,ALLOCUNIT*sizeof(host));
-    for (i=0;i<(ALLOCUNIT-1);i++) {
-      freehosts[i].next=&(freehosts[i+1]);
-    }
-    freehosts[ALLOCUNIT-1].next=NULL;
-  }
-  
-  nh=freehosts;
-  freehosts=nh->next;
-  
-  return nh;
+  return nsmalloc(POOL_NICK, sizeof(host));
 }
 
-void freehost (host *hp) {
-  hp->next=freehosts;
-  freehosts=hp;
+void freehost(host *hp) {
+  nsfree(POOL_NICK, hp);
 }