/* 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));
}
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]);
}
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]);
}
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;
-}