/* proxyscanalloc.c */
#include "proxyscan.h"
+#include "../core/nsmalloc.h"
#include <stdlib.h>
cachehost *freecachehosts;
pendingscan *freependingscans;
foundproxy *freefoundproxies;
-
-void *mallocs=NULL;
-
-void *smalloc(size_t size) {
- void **mem;
-
- /* Get the memory we want, with an extra four bytes for our pointer */
- mem=(void **)malloc(size+sizeof(void *));
-
- /* Set the first word to point at the last chunk we got */
- *mem=mallocs;
-
- /* Now set the "last chunk" pointer to the address of this one */
- mallocs=(void *)mem;
-
- /* Return the rest of the memory to the caller */
- return (void *)(mem+1);
-}
-
-void sfreeall() {
- void *vp,**vp2;
-
- vp=mallocs;
-
- while (vp!=NULL) {
- vp2=(void **)vp;
- vp=*vp2;
- free((void *)vp2);
- }
-}
+extrascan *freeextrascans;
scan *getscan() {
int i;
if (freescans==NULL) {
/* Eep. Allocate more. */
- freescans=(scan *)smalloc(ALLOCUNIT*sizeof(scan));
+ freescans=(scan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(scan));
for (i=0;i<(ALLOCUNIT-1);i++) {
freescans[i].next=&(freescans[i+1]);
}
cachehost *chp;
if (freecachehosts==NULL) {
- freecachehosts=(cachehost *)smalloc(ALLOCUNIT*sizeof(cachehost));
+ freecachehosts=(cachehost *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(cachehost));
for (i=0;i<(ALLOCUNIT-1);i++) {
freecachehosts[i].next=&(freecachehosts[i+1]);
}
pendingscan *psp;
if (!freependingscans) {
- freependingscans=(pendingscan *)smalloc(ALLOCUNIT * sizeof(pendingscan));
+ freependingscans=(pendingscan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(pendingscan));
for (i=0;i<(ALLOCUNIT-1);i++)
freependingscans[i].next = freependingscans+i+1;
freependingscans[ALLOCUNIT-1].next=NULL;
foundproxy *fpp;
if (!freefoundproxies) {
- freefoundproxies=(foundproxy *)smalloc(ALLOCUNIT * sizeof(foundproxy));
+ freefoundproxies=(foundproxy *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(foundproxy));
for (i=0;i<(ALLOCUNIT-1);i++)
freefoundproxies[i].next = freefoundproxies+i+1;
freefoundproxies[ALLOCUNIT-1].next=NULL;
freefoundproxies=fpp;
}
+extrascan *getextrascan() {
+ int i;
+ extrascan *esp;
+
+ if (freeextrascans==NULL) {
+ freeextrascans=(extrascan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(extrascan));
+ for (i=0;i<(ALLOCUNIT-1);i++) {
+ freeextrascans[i].next=&(freeextrascans[i+1]);
+ }
+ freeextrascans[ALLOCUNIT-1].next=NULL;
+ }
+
+ esp=freeextrascans;
+ freeextrascans=esp->next;
+
+ return esp;
+}
+
+void freeextrascan(extrascan *esp) {
+ esp->next=freeextrascans;
+ freeextrascans=esp;
+}
+