From: Gunnar Beutner Date: Tue, 30 Jul 2013 16:46:27 +0000 (+0200) Subject: Use nsmalloc/nsfree for proxyscan. X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/commitdiff_plain/05190f43e768b3d43f47e06b48f378cbab66f030 Use nsmalloc/nsfree for proxyscan. --- diff --git a/proxyscan/proxyscan.h b/proxyscan/proxyscan.h index 8395e891..627d7462 100644 --- a/proxyscan/proxyscan.h +++ b/proxyscan/proxyscan.h @@ -145,7 +145,6 @@ foundproxy *getfoundproxy(); void freefoundproxy(foundproxy *fpp); pendingscan *getpendingscan(); void freependingscan(pendingscan *psp); -void sfreeall(); extrascan *getextrascan(); void freeextrascan(extrascan *esp); diff --git a/proxyscan/proxyscanalloc.c b/proxyscan/proxyscanalloc.c index 5fb13ec3..733f2295 100644 --- a/proxyscan/proxyscanalloc.c +++ b/proxyscan/proxyscanalloc.c @@ -3,127 +3,43 @@ #include "proxyscan.h" #include "../core/nsmalloc.h" -#include - -#define ALLOCUNIT 1024 - -scan *freescans; -cachehost *freecachehosts; -pendingscan *freependingscans; -foundproxy *freefoundproxies; -extrascan *freeextrascans; - scan *getscan() { - int i; - scan *sp; - - if (freescans==NULL) { - /* Eep. Allocate more. */ - freescans=(scan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(scan)); - for (i=0;i<(ALLOCUNIT-1);i++) { - freescans[i].next=&(freescans[i+1]); - } - freescans[ALLOCUNIT-1].next=NULL; - } - - sp=freescans; - freescans=sp->next; - - return sp; + return nsmalloc(POOL_PROXYSCAN, sizeof(scan)); } void freescan(scan *sp) { - sp->next=freescans; - freescans=sp; + nsfree(POOL_PROXYSCAN, sp); } cachehost *getcachehost() { - int i; - cachehost *chp; - - if (freecachehosts==NULL) { - freecachehosts=(cachehost *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT*sizeof(cachehost)); - for (i=0;i<(ALLOCUNIT-1);i++) { - freecachehosts[i].next=&(freecachehosts[i+1]); - } - freecachehosts[ALLOCUNIT-1].next=NULL; - } - - chp=freecachehosts; - freecachehosts=chp->next; - - return chp; + return nsmalloc(POOL_PROXYSCAN, sizeof(cachehost)); } void freecachehost(cachehost *chp) { - chp->next=freecachehosts; - freecachehosts=chp; + nsfree(POOL_PROXYSCAN, chp); } pendingscan *getpendingscan() { - int i; - pendingscan *psp; - - if (!freependingscans) { - freependingscans=(pendingscan *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(pendingscan)); - for (i=0;i<(ALLOCUNIT-1);i++) - freependingscans[i].next = (pendingscan *)&(freependingscans[i+1]); - freependingscans[ALLOCUNIT-1].next=NULL; - } - - psp=freependingscans; - freependingscans=(pendingscan *)psp->next; - - return psp; + return nsmalloc(POOL_PROXYSCAN, sizeof(pendingscan)); } void freependingscan(pendingscan *psp) { - psp->next=freependingscans; - freependingscans=psp; + nsfree(POOL_PROXYSCAN, psp); } foundproxy *getfoundproxy() { - int i; - foundproxy *fpp; - - if (!freefoundproxies) { - freefoundproxies=(foundproxy *)nsmalloc(POOL_PROXYSCAN,ALLOCUNIT * sizeof(foundproxy)); - for (i=0;i<(ALLOCUNIT-1);i++) - freefoundproxies[i].next = (foundproxy *)&(freefoundproxies[i+1]); - freefoundproxies[ALLOCUNIT-1].next=NULL; - } - - fpp=freefoundproxies; - freefoundproxies=(foundproxy *)fpp->next; - - return fpp; + return nsmalloc(POOL_PROXYSCAN, sizeof(foundproxy)); } void freefoundproxy(foundproxy *fpp) { - fpp->next=freefoundproxies; - freefoundproxies=fpp; + nsfree(POOL_PROXYSCAN, 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; + return nsmalloc(POOL_PROXYSCAN, sizeof(extrascan)); } void freeextrascan(extrascan *esp) { - esp->next=freeextrascans; - freeextrascans=esp; + nsfree(POOL_PROXYSCAN, sizeof(extrascan)); }