]>
jfr.im git - irc/quakenet/newserv.git/blob - nick/nickalloc.c
395aec0a751a19a063a5582a579ce4df753465f6
1 /* nick/host/realname/authname allocator */
9 /* Hosts and realname structures are the same size */
10 /* This assumption is checked in initnickalloc(); */
14 authname
*freeauthnames
;
16 void initnickalloc() {
21 assert(sizeof(host
)==sizeof(realname
));
24 realname
*newrealname() {
25 return (realname
*)newhost();
28 void freerealname(realname
*rn
) {
36 if (freenicks
==NULL
) {
37 freenicks
=(nick
*)malloc(ALLOCUNIT
*sizeof(nick
));
38 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
39 freenicks
[i
].next
=&(freenicks
[i
+1]);
41 freenicks
[ALLOCUNIT
-1].next
=NULL
;
50 void freenick (nick
*np
) {
59 if (freehosts
==NULL
) {
60 freehosts
=(host
*)malloc(ALLOCUNIT
*sizeof(host
));
61 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
62 freehosts
[i
].next
=&(freehosts
[i
+1]);
64 freehosts
[ALLOCUNIT
-1].next
=NULL
;
73 void freehost (host
*hp
) {
78 authname
*newauthname() {
82 if (freeauthnames
==NULL
) {
83 freeauthnames
=(authname
*)malloc(ALLOCUNIT
*sizeof(authname
));
84 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
85 freeauthnames
[i
].next
=&(freeauthnames
[i
+1]);
87 freeauthnames
[ALLOCUNIT
-1].next
=NULL
;
91 freeauthnames
=anp
->next
;
96 void freeauthname (authname
*anp
) {
97 anp
->next
=freeauthnames
;