]>
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; | |
557c8cb2 | 14 | extrascan *freeextrascans; |
c86edd1d | 15 | |
c86edd1d Q |
16 | scan *getscan() { |
17 | int i; | |
18 | scan *sp; | |
19 | ||
20 | if (freescans==NULL) { | |
21 | /* Eep. Allocate more. */ | |
818e3d5f | 22 | freescans=(scan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(scan)); |
c86edd1d Q |
23 | for (i=0;i<(ALLOCUNIT-1);i++) { |
24 | freescans[i].next=&(freescans[i+1]); | |
25 | } | |
26 | freescans[ALLOCUNIT-1].next=NULL; | |
27 | } | |
28 | ||
29 | sp=freescans; | |
30 | freescans=sp->next; | |
31 | ||
32 | return sp; | |
33 | } | |
34 | ||
35 | void freescan(scan *sp) { | |
36 | sp->next=freescans; | |
37 | freescans=sp; | |
38 | } | |
39 | ||
40 | cachehost *getcachehost() { | |
41 | int i; | |
42 | cachehost *chp; | |
43 | ||
44 | if (freecachehosts==NULL) { | |
818e3d5f | 45 | freecachehosts=(cachehost *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(cachehost)); |
c86edd1d Q |
46 | for (i=0;i<(ALLOCUNIT-1);i++) { |
47 | freecachehosts[i].next=&(freecachehosts[i+1]); | |
48 | } | |
49 | freecachehosts[ALLOCUNIT-1].next=NULL; | |
50 | } | |
51 | ||
52 | chp=freecachehosts; | |
53 | freecachehosts=chp->next; | |
54 | ||
55 | return chp; | |
56 | } | |
57 | ||
58 | void freecachehost(cachehost *chp) { | |
59 | chp->next=freecachehosts; | |
60 | freecachehosts=chp; | |
61 | } | |
62 | ||
63 | pendingscan *getpendingscan() { | |
64 | int i; | |
65 | pendingscan *psp; | |
66 | ||
67 | if (!freependingscans) { | |
818e3d5f | 68 | freependingscans=(pendingscan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(pendingscan)); |
c86edd1d Q |
69 | for (i=0;i<(ALLOCUNIT-1);i++) |
70 | freependingscans[i].next = freependingscans+i+1; | |
71 | freependingscans[ALLOCUNIT-1].next=NULL; | |
72 | } | |
73 | ||
74 | psp=freependingscans; | |
75 | freependingscans=psp->next; | |
76 | ||
77 | return psp; | |
78 | } | |
79 | ||
80 | void freependingscan(pendingscan *psp) { | |
81 | psp->next=freependingscans; | |
82 | freependingscans=psp; | |
83 | } | |
84 | ||
85 | foundproxy *getfoundproxy() { | |
86 | int i; | |
87 | foundproxy *fpp; | |
88 | ||
89 | if (!freefoundproxies) { | |
818e3d5f | 90 | freefoundproxies=(foundproxy *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(foundproxy)); |
c86edd1d Q |
91 | for (i=0;i<(ALLOCUNIT-1);i++) |
92 | freefoundproxies[i].next = freefoundproxies+i+1; | |
93 | freefoundproxies[ALLOCUNIT-1].next=NULL; | |
94 | } | |
95 | ||
96 | fpp=freefoundproxies; | |
97 | freefoundproxies=fpp->next; | |
98 | ||
99 | return fpp; | |
100 | } | |
101 | ||
102 | void freefoundproxy(foundproxy *fpp) { | |
103 | fpp->next=freefoundproxies; | |
104 | freefoundproxies=fpp; | |
105 | } | |
106 | ||
557c8cb2 P |
107 | extrascan *getextrascan() { |
108 | int i; | |
109 | extrascan *esp; | |
110 | ||
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]); | |
115 | } | |
116 | freeextrascans[ALLOCUNIT-1].next=NULL; | |
117 | } | |
118 | ||
119 | esp=freeextrascans; | |
120 | freeextrascans=esp->next; | |
121 | ||
122 | return esp; | |
123 | } | |
124 | ||
125 | void freeextrascan(extrascan *esp) { | |
126 | esp->next=freeextrascans; | |
127 | freeextrascans=esp; | |
128 | } | |
129 |