]> jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanalloc.c
5fb13ec3c7fb213396c00f51f81122c99d6d27a7
[irc/quakenet/newserv.git] / proxyscan / proxyscanalloc.c
1 /* proxyscanalloc.c */
2
3 #include "proxyscan.h"
4 #include "../core/nsmalloc.h"
5
6 #include <stdlib.h>
7
8 #define ALLOCUNIT 1024
9
10 scan *freescans;
11 cachehost *freecachehosts;
12 pendingscan *freependingscans;
13 foundproxy *freefoundproxies;
14 extrascan *freeextrascans;
15
16 scan *getscan() {
17 int i;
18 scan *sp;
19
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]);
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) {
45 freecachehosts=(cachehost *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(cachehost));
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) {
68 freependingscans=(pendingscan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(pendingscan));
69 for (i=0;i<(ALLOCUNIT-1);i++)
70 freependingscans[i].next = (pendingscan *)&(freependingscans[i+1]);
71 freependingscans[ALLOCUNIT-1].next=NULL;
72 }
73
74 psp=freependingscans;
75 freependingscans=(pendingscan *)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) {
90 freefoundproxies=(foundproxy *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(foundproxy));
91 for (i=0;i<(ALLOCUNIT-1);i++)
92 freefoundproxies[i].next = (foundproxy *)&(freefoundproxies[i+1]);
93 freefoundproxies[ALLOCUNIT-1].next=NULL;
94 }
95
96 fpp=freefoundproxies;
97 freefoundproxies=(foundproxy *)fpp->next;
98
99 return fpp;
100 }
101
102 void freefoundproxy(foundproxy *fpp) {
103 fpp->next=freefoundproxies;
104 freefoundproxies=fpp;
105 }
106
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