]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanalloc.c
4 #include "../core/nsmalloc.h"
11 cachehost
*freecachehosts
;
12 pendingscan
*freependingscans
;
13 foundproxy
*freefoundproxies
;
14 extrascan
*freeextrascans
;
20 if (freescans
==NULL
) {
21 /* Eep. Allocate more. */
22 freescans
=(scan
*)nsmalloc(POOL_PROXYSCAN
,ALLOCUNIT
*sizeof(scan
));
23 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
24 freescans
[i
].next
=&(freescans
[i
+1]);
26 freescans
[ALLOCUNIT
-1].next
=NULL
;
35 void freescan(scan
*sp
) {
40 cachehost
*getcachehost() {
44 if (freecachehosts
==NULL
) {
45 freecachehosts
=(cachehost
*)nsmalloc(POOL_PROXYSCAN
,ALLOCUNIT
*sizeof(cachehost
));
46 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
47 freecachehosts
[i
].next
=&(freecachehosts
[i
+1]);
49 freecachehosts
[ALLOCUNIT
-1].next
=NULL
;
53 freecachehosts
=chp
->next
;
58 void freecachehost(cachehost
*chp
) {
59 chp
->next
=freecachehosts
;
63 pendingscan
*getpendingscan() {
67 if (!freependingscans
) {
68 freependingscans
=(pendingscan
*)nsmalloc(POOL_PROXYSCAN
,ALLOCUNIT
* sizeof(pendingscan
));
69 for (i
=0;i
<(ALLOCUNIT
-1);i
++)
70 freependingscans
[i
].next
= freependingscans
+i
+1;
71 freependingscans
[ALLOCUNIT
-1].next
=NULL
;
75 freependingscans
=psp
->next
;
80 void freependingscan(pendingscan
*psp
) {
81 psp
->next
=freependingscans
;
85 foundproxy
*getfoundproxy() {
89 if (!freefoundproxies
) {
90 freefoundproxies
=(foundproxy
*)nsmalloc(POOL_PROXYSCAN
,ALLOCUNIT
* sizeof(foundproxy
));
91 for (i
=0;i
<(ALLOCUNIT
-1);i
++)
92 freefoundproxies
[i
].next
= freefoundproxies
+i
+1;
93 freefoundproxies
[ALLOCUNIT
-1].next
=NULL
;
97 freefoundproxies
=fpp
->next
;
102 void freefoundproxy(foundproxy
*fpp
) {
103 fpp
->next
=freefoundproxies
;
104 freefoundproxies
=fpp
;
107 extrascan
*getextrascan() {
111 if (freeextrascans
==NULL
) {
112 freeextrascans
=(extrascan
*)nsmalloc(POOL_PROXYSCAN
,ALLOCUNIT
*sizeof(extrascan
));
113 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
114 freeextrascans
[i
].next
=&(freeextrascans
[i
+1]);
116 freeextrascans
[ALLOCUNIT
-1].next
=NULL
;
120 freeextrascans
=esp
->next
;
125 void freeextrascan(extrascan
*esp
) {
126 esp
->next
=freeextrascans
;