]>
Commit | Line | Data |
---|---|---|
c86edd1d Q |
1 | /* proxyscanalloc.c */ |
2 | ||
3 | #include "proxyscan.h" | |
818e3d5f | 4 | #include "../core/nsmalloc.h" |
c86edd1d Q |
5 | |
6 | #include <stdlib.h> | |
7 | ||
8 | #define ALLOCUNIT 1024 | |
9 | ||
10 | scan *freescans; | |
11 | cachehost *freecachehosts; | |
12 | pendingscan *freependingscans; | |
13 | foundproxy *freefoundproxies; | |
14 | ||
c86edd1d Q |
15 | scan *getscan() { |
16 | int i; | |
17 | scan *sp; | |
18 | ||
19 | if (freescans==NULL) { | |
20 | /* Eep. Allocate more. */ | |
818e3d5f | 21 | freescans=(scan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(scan)); |
c86edd1d Q |
22 | for (i=0;i<(ALLOCUNIT-1);i++) { |
23 | freescans[i].next=&(freescans[i+1]); | |
24 | } | |
25 | freescans[ALLOCUNIT-1].next=NULL; | |
26 | } | |
27 | ||
28 | sp=freescans; | |
29 | freescans=sp->next; | |
30 | ||
31 | return sp; | |
32 | } | |
33 | ||
34 | void freescan(scan *sp) { | |
35 | sp->next=freescans; | |
36 | freescans=sp; | |
37 | } | |
38 | ||
39 | cachehost *getcachehost() { | |
40 | int i; | |
41 | cachehost *chp; | |
42 | ||
43 | if (freecachehosts==NULL) { | |
818e3d5f | 44 | freecachehosts=(cachehost *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(cachehost)); |
c86edd1d Q |
45 | for (i=0;i<(ALLOCUNIT-1);i++) { |
46 | freecachehosts[i].next=&(freecachehosts[i+1]); | |
47 | } | |
48 | freecachehosts[ALLOCUNIT-1].next=NULL; | |
49 | } | |
50 | ||
51 | chp=freecachehosts; | |
52 | freecachehosts=chp->next; | |
53 | ||
54 | return chp; | |
55 | } | |
56 | ||
57 | void freecachehost(cachehost *chp) { | |
58 | chp->next=freecachehosts; | |
59 | freecachehosts=chp; | |
60 | } | |
61 | ||
62 | pendingscan *getpendingscan() { | |
63 | int i; | |
64 | pendingscan *psp; | |
65 | ||
66 | if (!freependingscans) { | |
818e3d5f | 67 | freependingscans=(pendingscan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(pendingscan)); |
c86edd1d Q |
68 | for (i=0;i<(ALLOCUNIT-1);i++) |
69 | freependingscans[i].next = freependingscans+i+1; | |
70 | freependingscans[ALLOCUNIT-1].next=NULL; | |
71 | } | |
72 | ||
73 | psp=freependingscans; | |
74 | freependingscans=psp->next; | |
75 | ||
76 | return psp; | |
77 | } | |
78 | ||
79 | void freependingscan(pendingscan *psp) { | |
80 | psp->next=freependingscans; | |
81 | freependingscans=psp; | |
82 | } | |
83 | ||
84 | foundproxy *getfoundproxy() { | |
85 | int i; | |
86 | foundproxy *fpp; | |
87 | ||
88 | if (!freefoundproxies) { | |
818e3d5f | 89 | freefoundproxies=(foundproxy *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(foundproxy)); |
c86edd1d Q |
90 | for (i=0;i<(ALLOCUNIT-1);i++) |
91 | freefoundproxies[i].next = freefoundproxies+i+1; | |
92 | freefoundproxies[ALLOCUNIT-1].next=NULL; | |
93 | } | |
94 | ||
95 | fpp=freefoundproxies; | |
96 | freefoundproxies=fpp->next; | |
97 | ||
98 | return fpp; | |
99 | } | |
100 | ||
101 | void freefoundproxy(foundproxy *fpp) { | |
102 | fpp->next=freefoundproxies; | |
103 | freefoundproxies=fpp; | |
104 | } | |
105 |