]>
jfr.im git - irc/quakenet/newserv.git/blob - nick/nickalloc.c
1 /* nick/host/realname/authname allocator */
4 #include "../core/nsmalloc.h"
11 /* Hosts and realname structures are the same size */
12 /* This assumption is checked in initnickalloc(); */
17 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
*)nsmalloc(POOL_NICK
,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
*)nsmalloc(POOL_NICK
,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
) {