]>
jfr.im git - irc/quakenet/newserv.git/blob - nick/nickalloc.c
1 /* nick/host/realname/authname allocator */
9 /* Hosts and realname structures are the same size */
10 /* This assumption is checked in initnickalloc(); */
15 void initnickalloc() {
19 assert(sizeof(host
)==sizeof(realname
));
22 realname
*newrealname() {
23 return (realname
*)newhost();
26 void freerealname(realname
*rn
) {
34 if (freenicks
==NULL
) {
35 freenicks
=(nick
*)malloc(ALLOCUNIT
*sizeof(nick
));
36 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
37 freenicks
[i
].next
=&(freenicks
[i
+1]);
39 freenicks
[ALLOCUNIT
-1].next
=NULL
;
48 void freenick (nick
*np
) {
57 if (freehosts
==NULL
) {
58 freehosts
=(host
*)malloc(ALLOCUNIT
*sizeof(host
));
59 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
60 freehosts
[i
].next
=&(freehosts
[i
+1]);
62 freehosts
[ALLOCUNIT
-1].next
=NULL
;
71 void freehost (host
*hp
) {