]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanalloc.c
10 cachehost
*freecachehosts
;
11 pendingscan
*freependingscans
;
12 foundproxy
*freefoundproxies
;
16 void *smalloc(size_t size
) {
19 /* Get the memory we want, with an extra four bytes for our pointer */
20 mem
=(void **)malloc(size
+sizeof(void *));
22 /* Set the first word to point at the last chunk we got */
25 /* Now set the "last chunk" pointer to the address of this one */
28 /* Return the rest of the memory to the caller */
29 return (void *)(mem
+1);
48 if (freescans
==NULL
) {
49 /* Eep. Allocate more. */
50 freescans
=(scan
*)smalloc(ALLOCUNIT
*sizeof(scan
));
51 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
52 freescans
[i
].next
=&(freescans
[i
+1]);
54 freescans
[ALLOCUNIT
-1].next
=NULL
;
63 void freescan(scan
*sp
) {
68 cachehost
*getcachehost() {
72 if (freecachehosts
==NULL
) {
73 freecachehosts
=(cachehost
*)smalloc(ALLOCUNIT
*sizeof(cachehost
));
74 for (i
=0;i
<(ALLOCUNIT
-1);i
++) {
75 freecachehosts
[i
].next
=&(freecachehosts
[i
+1]);
77 freecachehosts
[ALLOCUNIT
-1].next
=NULL
;
81 freecachehosts
=chp
->next
;
86 void freecachehost(cachehost
*chp
) {
87 chp
->next
=freecachehosts
;
91 pendingscan
*getpendingscan() {
95 if (!freependingscans
) {
96 freependingscans
=(pendingscan
*)smalloc(ALLOCUNIT
* sizeof(pendingscan
));
97 for (i
=0;i
<(ALLOCUNIT
-1);i
++)
98 freependingscans
[i
].next
= freependingscans
+i
+1;
99 freependingscans
[ALLOCUNIT
-1].next
=NULL
;
102 psp
=freependingscans
;
103 freependingscans
=psp
->next
;
108 void freependingscan(pendingscan
*psp
) {
109 psp
->next
=freependingscans
;
110 freependingscans
=psp
;
113 foundproxy
*getfoundproxy() {
117 if (!freefoundproxies
) {
118 freefoundproxies
=(foundproxy
*)smalloc(ALLOCUNIT
* sizeof(foundproxy
));
119 for (i
=0;i
<(ALLOCUNIT
-1);i
++)
120 freefoundproxies
[i
].next
= freefoundproxies
+i
+1;
121 freefoundproxies
[ALLOCUNIT
-1].next
=NULL
;
124 fpp
=freefoundproxies
;
125 freefoundproxies
=fpp
->next
;
130 void freefoundproxy(foundproxy
*fpp
) {
131 fpp
->next
=freefoundproxies
;
132 freefoundproxies
=fpp
;