]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Use nsmalloc/nsfree for proxyscan.
authorGunnar Beutner <redacted>
Tue, 30 Jul 2013 16:46:27 +0000 (18:46 +0200)
committerGunnar Beutner <redacted>
Tue, 30 Jul 2013 16:46:27 +0000 (18:46 +0200)
proxyscan/proxyscan.h
proxyscan/proxyscanalloc.c

index 8395e891e261baa33069eac04dda9103327acc39..627d7462e6ebfc538c62a5ddc907391c0bdec449 100644 (file)
@@ -145,7 +145,6 @@ foundproxy *getfoundproxy();
 void freefoundproxy(foundproxy *fpp);
 pendingscan *getpendingscan();
 void freependingscan(pendingscan *psp);
-void sfreeall();
 extrascan *getextrascan();
 void freeextrascan(extrascan *esp);
 
index 5fb13ec3c7fb213396c00f51f81122c99d6d27a7..733f2295098b75b8a1625fce134663fad265a409 100644 (file)
 #include "proxyscan.h"
 #include "../core/nsmalloc.h"
 
-#include <stdlib.h>
-
-#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));
 }