]> jfr.im git - irc/quakenet/newserv.git/blame - proxyscan/proxyscanalloc.c
merge
[irc/quakenet/newserv.git] / proxyscan / proxyscanalloc.c
CommitLineData
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
10scan *freescans;
11cachehost *freecachehosts;
12pendingscan *freependingscans;
13foundproxy *freefoundproxies;
557c8cb2 14extrascan *freeextrascans;
c86edd1d 15
c86edd1d
Q
16scan *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
35void freescan(scan *sp) {
36 sp->next=freescans;
37 freescans=sp;
38}
39
40cachehost *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
58void freecachehost(cachehost *chp) {
59 chp->next=freecachehosts;
60 freecachehosts=chp;
61}
62
63pendingscan *getpendingscan() {
64 int i;
65 pendingscan *psp;
66
67 if (!freependingscans) {
818e3d5f 68 freependingscans=(pendingscan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(pendingscan));
c86edd1d 69 for (i=0;i<(ALLOCUNIT-1);i++)
7ab80d0c 70 freependingscans[i].next = (pendingscan *)&(freependingscans[i+1]);
c86edd1d
Q
71 freependingscans[ALLOCUNIT-1].next=NULL;
72 }
73
74 psp=freependingscans;
7ab80d0c 75 freependingscans=(pendingscan *)psp->next;
c86edd1d
Q
76
77 return psp;
78}
79
80void freependingscan(pendingscan *psp) {
81 psp->next=freependingscans;
82 freependingscans=psp;
83}
84
85foundproxy *getfoundproxy() {
86 int i;
87 foundproxy *fpp;
88
89 if (!freefoundproxies) {
818e3d5f 90 freefoundproxies=(foundproxy *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(foundproxy));
c86edd1d 91 for (i=0;i<(ALLOCUNIT-1);i++)
7ab80d0c 92 freefoundproxies[i].next = (foundproxy *)&(freefoundproxies[i+1]);
c86edd1d
Q
93 freefoundproxies[ALLOCUNIT-1].next=NULL;
94 }
95
96 fpp=freefoundproxies;
7ab80d0c 97 freefoundproxies=(foundproxy *)fpp->next;
c86edd1d
Q
98
99 return fpp;
100}
101
102void freefoundproxy(foundproxy *fpp) {
103 fpp->next=freefoundproxies;
104 freefoundproxies=fpp;
105}
106
557c8cb2
P
107extrascan *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
125void freeextrascan(extrascan *esp) {
126 esp->next=freeextrascans;
127 freeextrascans=esp;
128}
129