From: robertc <> Date: Mon, 30 Aug 2004 11:12:29 +0000 (+0000) Subject: Merge in MemPools objectification. X-Git-Tag: SQUID_3_0_PRE4~1067 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b001e8228f73e930471b420c7f2451527adb63f4;p=thirdparty%2Fsquid.git Merge in MemPools objectification. Patches applied: * robertc@squid-cache.org--squid/squid--MemPools--3.0--base-0 tag of robertc@squid-cache.org--squid/squid--HEAD--3.0--patch-369 * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-1 MemPools C++ rework. * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-2 Tidying up. * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-3 merge from HEAD * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-4 merge from HEAD * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-5 merge from HEAD * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-6 fix up remaining splay tweaks for mempools, and update test suite * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-7 Allow runtime pool type selection. * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-8 MemProxyAllocator changes. * robertc@squid-cache.org--squid/squid--MemPools--3.0--patch-9 merge latest head changes --- diff --git a/configure.in b/configure.in index a7551fed47..5e0c9c1ce7 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.357 2004/08/30 03:28:45 robertc Exp $ +dnl $Id: configure.in,v 1.358 2004/08/30 05:12:29 robertc Exp $ dnl dnl dnl @@ -13,7 +13,7 @@ AC_CONFIG_SRCDIR([src/main.cc]) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 3.0-PRE3-CVS) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.357 $)dnl +AC_REVISION($Revision: 1.358 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1273,8 +1273,12 @@ fi AC_SUBST(EXTERNAL_ACL_HELPERS) dnl Disable "memPools" code +AC_DEFINE(DISABLE_POOLS, 0, [Define if you have problems with memPools and want to disable Pools.]) AC_ARG_ENABLE(mempools, -[ --disable-mempools Disable memPools], +[ --disable-mempools Disable memPools. Note that this option now simply sets the + default behaviour. Specific classes can override this at runtime, and + only lib/MemPool.c needs to be altered to change the squid-wide + default for all classes.], [ if test "$enableval" = "no" ; then echo "memPools disabled" AC_DEFINE(DISABLE_POOLS, 1, [Define if you have problems with memPools and want to disable Pools]) diff --git a/include/List.h b/include/List.h index d59e6dfec3..bfe9eb6a16 100644 --- a/include/List.h +++ b/include/List.h @@ -1,6 +1,6 @@ /* - * $Id: List.h,v 1.3 2003/08/04 22:14:37 robertc Exp $ + * $Id: List.h,v 1.4 2004/08/30 05:12:29 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -52,10 +52,6 @@ public: private: CBDATA_CLASS(List); -#if 0 - - static MemPool *Pool; -#endif }; template @@ -86,17 +82,6 @@ template void * List::operator new (size_t byteCount) { -#if 0 - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (List)); - - if (!Pool) - Pool = memPoolCreate("List", sizeof (List)); - - return memPoolAlloc(Pool); - -#endif - CBDATA_INIT_TYPE(List); List *result = cbdataAlloc(List); @@ -108,8 +93,6 @@ template void List::operator delete (void *address) { - // MemPoolFree - // List *t = static_cast *>(address); cbdataFree(address); } diff --git a/include/MemPool.h b/include/MemPool.h index abb26f9d4e..628c89ba40 100644 --- a/include/MemPool.h +++ b/include/MemPool.h @@ -4,18 +4,9 @@ #include "config.h" #include "util.h" -#ifdef __cplusplus -template - -class SplayNode; - -typedef SplayNode splayNode; - -#else -#include "splay.h" -#endif #include "memMeter.h" +#include "splay.h" #if HAVE_GNUMALLOC_H #include @@ -33,10 +24,6 @@ typedef SplayNode splayNode; #endif #endif -#if PURIFY -#define DISABLE_POOLS 1 /* Disabling Memory pools under purify */ -#endif - #define MB ((size_t)1024*1024) #define mem_unlimited_size 2 * 1024 * MB #define toMB(size) ( ((double) size) / MB ) @@ -48,38 +35,35 @@ typedef SplayNode splayNode; #define MEM_MIN_FREE 32 #define MEM_MAX_FREE 65535 /* ushort is max number of items per chunk */ -typedef struct _MemPoolMeter MemPoolMeter; - -typedef struct _MemPool MemPool; - -typedef struct _MemChunk MemChunk; - -typedef struct _MemPoolStats MemPoolStats; +class MemImplementingAllocator; +class MemChunk; +class MemPoolStats; typedef struct _MemPoolGlobalStats MemPoolGlobalStats; -typedef struct _MemPoolIterator MemPoolIterator; - -struct _MemPoolIterator +class MemPoolIterator { - MemPool *pool; + public: + MemImplementingAllocator *pool; MemPoolIterator * next; }; /* object to track per-pool cumulative counters */ -typedef struct +class mgb_t { + public: + mgb_t() : count(0), bytes(0){} double count; double bytes; -} - -mgb_t; +}; /* object to track per-pool memory usage (alloc = inuse+idle) */ -struct _MemPoolMeter +class MemPoolMeter { + public: + void flush(); MemMeter alloc; MemMeter inuse; MemMeter idle; @@ -88,41 +72,184 @@ struct _MemPoolMeter mgb_t gb_freed; /* account Free calls */ }; +class MemImplementingAllocator; + +class MemPools +{ + public: + static MemPools &GetInstance(); + MemPools(); + void init(); + void flushMeters(); + MemImplementingAllocator * create(const char *label, size_t obj_size); + MemImplementingAllocator * create(const char *label, size_t obj_size, bool const chunked); + void setIdleLimit(size_t new_idle_limit); + size_t const idleLimit() const; + void clean(time_t maxage); + void setDefaultPoolChunking(bool const &); + MemImplementingAllocator *pools; + int mem_idle_limit; + int poolCount; + bool defaultIsChunked; + private: + static MemPools *Instance; +}; + /* a pool is a [growing] space for objects of the same size */ -struct _MemPool +class MemAllocator +{ +public: + MemAllocator (char const *aLabel); + virtual ~MemAllocator() {} + virtual int getStats(MemPoolStats * stats) = 0; + virtual MemPoolMeter const &getMeter() const = 0; + virtual void *alloc() = 0; + virtual void free(void *) = 0; + virtual char const *objectType() const; + virtual size_t objectSize() const = 0; +private: + const char *label; +}; + +/* Support late binding of pool type for allocator agnostic classes */ +class MemAllocatorProxy { + public: + inline MemAllocatorProxy(char const *aLabel, size_t const &); + void *alloc(); + void free(void *); + int inUseCount() const; + size_t objectSize() const; + MemPoolMeter const &getMeter() const; + int getStats(MemPoolStats * stats); + char const * objectType() const; + private: + MemAllocator *getAllocator() const; const char *label; + size_t size; + mutable MemAllocator *theAllocator; +}; +/* help for classes */ +/* Put this in the class */ +#define MEMPROXY_CLASS(CLASS) \ +/* TODO change syntax to allow moving into .cci files */ \ + inline void *operator new(size_t); \ + inline void operator delete(void *); \ + static inline MemAllocatorProxy &Pool() + +/* put this in the class .h, or .cci as appropriate */ +#define MEMPROXY_CLASS_INLINE(CLASS) \ +MemAllocatorProxy& CLASS::Pool() \ +{ \ + static MemAllocatorProxy thePool(#CLASS, sizeof (CLASS)); \ + return thePool; \ +} \ +\ +void * \ +CLASS::operator new (size_t byteCount) \ +{ \ + /* derived classes with different sizes must implement their own new */ \ + assert (byteCount == sizeof (CLASS)); \ +\ + return Pool().alloc(); \ +} \ +\ +void \ +CLASS::operator delete (void *address) \ +{ \ + Pool().free(address); \ +} + +class MemImplementingAllocator : public MemAllocator +{ + public: + MemImplementingAllocator(char const *aLabel, size_t aSize); + virtual MemPoolMeter const &getMeter() const; + virtual MemPoolMeter &getMeter(); + virtual void flushMetersFull(); + virtual void flushMeters(); + virtual void *alloc(); + virtual void free(void *); + virtual bool idleTrigger(int shift) const = 0; + virtual void clean(time_t maxage) = 0; + /* Hint to the allocator - may be ignored */ + virtual void setChunkSize(size_t chunksize) {} + virtual size_t objectSize() const; + protected: + virtual void *allocate() = 0; + virtual void deallocate(void *) = 0; + private: + MemPoolMeter meter; + public: + MemImplementingAllocator *next; + public: + size_t alloc_calls; + size_t free_calls; size_t obj_size; +}; + +class MemPool : public MemImplementingAllocator +{ + public: + friend class MemChunk; + MemPool(const char *label, size_t obj_size); + ~MemPool(); + void convertFreeCacheToChunkFreeCache(); + virtual void clean(time_t maxage); + virtual int getStats(MemPoolStats * stats); + void createChunk(); + void *get(); + void push(void *obj); + protected: + virtual void *allocate(); + virtual void deallocate(void *); + public: + virtual void setChunkSize(size_t chunksize); + virtual bool idleTrigger(int shift) const; + size_t chunk_size; int chunk_capacity; int memPID; int chunkCount; - size_t alloc_calls; - size_t free_calls; size_t inuse; size_t idle; void *freeCache; MemChunk *nextFreeChunk; MemChunk *Chunks; - MemPoolMeter meter; - splayNode *allChunks; - MemPool *next; + Splay allChunks; +}; + +class MemMalloc : public MemImplementingAllocator +{ + public: + MemMalloc(char const *label, size_t aSize); + virtual bool idleTrigger(int shift) const; + virtual void clean(time_t maxage); + virtual int getStats(MemPoolStats * stats); + protected: + virtual void *allocate(); + virtual void deallocate(void *); }; -struct _MemChunk +class MemChunk { + public: + MemChunk(MemPool *pool); + ~MemChunk(); void *freeList; void *objCache; int inuse_count; MemChunk *nextFreeChunk; MemChunk *next; time_t lastref; + MemPool *pool; }; -struct _MemPoolStats +class MemPoolStats { - MemPool *pool; + public: + MemAllocator *pool; const char *label; MemPoolMeter *meter; int obj_size; @@ -164,32 +291,20 @@ struct _MemPoolGlobalStats #define SIZEOF_CHUNK ( ( sizeof(MemChunk) + sizeof(double) -1) / sizeof(double) ) * sizeof(double); -/* memPools */ - /* Allocator API */ -SQUIDCEXTERN MemPool *memPoolCreate(const char *label, size_t obj_size); -SQUIDCEXTERN void *memPoolAlloc(MemPool * pool); -SQUIDCEXTERN void memPoolFree(MemPool * pool, void *obj); -SQUIDCEXTERN void memPoolDestroy(MemPool ** pool); - -SQUIDCEXTERN MemPoolIterator * memPoolIterate(void); -SQUIDCEXTERN MemPool * memPoolIterateNext(MemPoolIterator * iter); -SQUIDCEXTERN void memPoolIterateDone(MemPoolIterator ** iter); +extern MemPoolIterator * memPoolIterate(void); +extern MemImplementingAllocator * memPoolIterateNext(MemPoolIterator * iter); +extern void memPoolIterateDone(MemPoolIterator ** iter); -/* Tune API */ -SQUIDCEXTERN void memPoolSetChunkSize(MemPool * pool, size_t chunksize); -SQUIDCEXTERN void memPoolSetIdleLimit(size_t new_idle_limit); +/* Stats API - not sured how to refactor yet */ +extern int memPoolGetGlobalStats(MemPoolGlobalStats * stats); -/* Stats API */ -SQUIDCEXTERN int memPoolGetStats(MemPoolStats * stats, MemPool * pool); -SQUIDCEXTERN int memPoolGetGlobalStats(MemPoolGlobalStats * stats); +extern int memPoolInUseCount(MemAllocator *); +extern int memPoolsTotalAllocated(void); -/* Module housekeeping API */ -SQUIDCEXTERN void memPoolClean(time_t maxage); +MemAllocatorProxy::MemAllocatorProxy(char const *aLabel, size_t const &aSize) : label (aLabel), size(aSize), theAllocator (NULL) +{ +} -#if UNUSED -/* Stats history API */ -SQUIDCEXTERN void memPoolCheckRates(); /* stats history checkpoints */ -#endif #endif /* _MEM_POOLS_H_ */ diff --git a/include/memMeter.h b/include/memMeter.h index b353f33c49..1a3bc6cc1c 100644 --- a/include/memMeter.h +++ b/include/memMeter.h @@ -2,10 +2,10 @@ #ifndef _MEM_METER_H_ #define _MEM_METER_H_ -typedef struct _MemMeter MemMeter; - /* object to track per-action memory usage (e.g. #idle objects) */ -struct _MemMeter { +class MemMeter { + public: + MemMeter() : level(0), hwater_level(0), hwater_stamp(0) {} ssize_t level; /* current level (count or volume) */ ssize_t hwater_level; /* high water mark */ time_t hwater_stamp; /* timestamp of last high water mark change */ diff --git a/include/splay.h b/include/splay.h index 96be7ca714..854c40926d 100644 --- a/include/splay.h +++ b/include/splay.h @@ -1,34 +1,11 @@ /* - * $Id: splay.h,v 1.26 2003/09/22 08:50:51 robertc Exp $ + * $Id: splay.h,v 1.27 2004/08/30 05:12:29 robertc Exp $ */ #ifndef SQUID_SPLAY_H #define SQUID_SPLAY_H #ifndef __cplusplus -/* legacy C bindings - can be removed when mempool is C++ */ - -typedef struct _splay_node -{ - void *data; - - struct _splay_node *left; - - struct _splay_node *right; -} - -splayNode; - -typedef int SPLAYCMP(const void **a, const void **b); -typedef void SPLAYWALKEE(void **nodedata, void *state); - -SQUIDCEXTERN int splayLastResult; - -/* MUST match C++ prototypes */ -SQUIDCEXTERN splayNode *splay_insert(void *, splayNode *, SPLAYCMP *); -SQUIDCEXTERN splayNode *splay_splay(const void **, splayNode *, SPLAYCMP *); -SQUIDCEXTERN splayNode *splay_delete(const void *, splayNode *, SPLAYCMP *); -SQUIDCEXTERN void splay_walk(splayNode *, SPLAYWALKEE *, void *); #else #include "Stack.h" @@ -59,7 +36,7 @@ public: SplayNode * insert(Value data, SPLAYCMP * compare); - SplayNode * splay(const Value &data, SPLAYCMP * compare) const; + template SplayNode * splay(const FindValue &data, int( * compare)(FindValue const &a, Value const &b)) const; }; typedef SplayNode splayNode; @@ -86,7 +63,7 @@ public: Splay():head(NULL), elements (0){} mutable SplayNode * head; - Value const *find (Value const &, SPLAYCMP *compare) const; + template Value const *find (FindValue const &, int( * compare)(FindValue const &a, Value const &b)) const; void insert(Value const &, SPLAYCMP *compare); void remove @@ -240,8 +217,9 @@ SplayNode::insert(Value dataToInsert, SPLAYCMP * compare) } template +template SplayNode * -SplayNode::splay(Value const &dataToFind, SPLAYCMP * compare) const +SplayNode::splay(FindValue const &dataToFind, int( * compare)(FindValue const &a, Value const &b)) const { if (this == NULL) { /* can't have compared successfully :} */ @@ -249,7 +227,8 @@ SplayNode::splay(Value const &dataToFind, SPLAYCMP * compare) const return NULL; } - SplayNode N(dataToFind); + Value temp = Value(); + SplayNode N(temp); SplayNode *l; SplayNode *r; SplayNode *y; @@ -308,8 +287,9 @@ SplayNode::splay(Value const &dataToFind, SPLAYCMP * compare) const } template +template typename Splay::Value const * -Splay::find (Value const &value, SPLAYCMP *compare) const +Splay::find (FindValue const &value, int( * compare)(FindValue const &a, Value const &b)) const { head = head->splay(value, compare); diff --git a/lib/Makefile.am b/lib/Makefile.am index 224e820a51..a10faa25bc 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in # -# $Id: Makefile.am,v 1.13 2004/08/30 03:28:54 robertc Exp $ +# $Id: Makefile.am,v 1.14 2004/08/30 05:12:30 robertc Exp $ # DIST_SUBDIRS = libTrie cppunit-1.10.0 @@ -39,7 +39,7 @@ EXTRA_libmiscutil_a_SOURCES = \ Profiler.c \ snprintf.c libmiscutil_a_SOURCES = \ - MemPool.c \ + MemPool.cc \ base64.c \ getfullhostname.c \ hash.c \ diff --git a/lib/Splay.cc b/lib/Splay.cc index c53f49968d..da84822eb3 100644 --- a/lib/Splay.cc +++ b/lib/Splay.cc @@ -1,5 +1,5 @@ /* - * $Id: Splay.cc,v 1.2 2003/02/08 01:45:47 robertc Exp $ + * $Id: Splay.cc,v 1.3 2004/08/30 05:12:30 robertc Exp $ * * based on ftp://ftp.cs.cmu.edu/user/sleator/splaying/top-down-splay.c * http://bobo.link.cs.cmu.edu/cgi-bin/splay/splay-cgi.pl @@ -21,59 +21,3 @@ #include "util.h" int splayLastResult = 0; - -splayNode * -splay_insert(void *data, splayNode * top, splayNode::SPLAYCMP * compare) -{ - return top->insert (data, compare); -} - -splayNode * -splay_splay(const void **data, splayNode * top, splayNode::SPLAYCMP * compare) -{ - return top->splay((void * const)*data, compare); -} - -splayNode * -splay_delete(const void *data, splayNode * top, splayNode::SPLAYCMP * compare) -{ - return top->remove ((void * const)data, compare); -} - -void -splay_destroy(splayNode * top, splayNode::SPLAYFREE * free_func) -{ - top->destroy(free_func); -} - -void -splay_walk(splayNode * top, splayNode::SPLAYWALKEE * walkee, void *state) -{ - top->walk(walkee,state); -} - -#ifdef DEBUG -void -splay_dump_entry(void *data, int depth) -{ - printf("%*s%s\n", depth, "", (char *) data); -} - -static void -splay_do_dump(splayNode * top, void printfunc(void *data, int depth), int depth) -{ - if (!top) - return; - splay_do_dump(top->left, printfunc, depth + 1); - printfunc(top->data, depth); - splay_do_dump(top->right, printfunc, depth + 1); -} - -void -splay_dump(splayNode * top, void printfunc(void *data, int depth)) -{ - splay_do_dump(top, printfunc, 0); -} - - -#endif diff --git a/lib/uudecode.c b/lib/uudecode.c index 73ada954a9..a193a8937c 100644 --- a/lib/uudecode.c +++ b/lib/uudecode.c @@ -1,5 +1,5 @@ /* - * $Id: uudecode.c,v 1.10 2003/01/23 00:37:02 robertc Exp $ + * $Id: uudecode.c,v 1.11 2004/08/30 05:12:30 robertc Exp $ */ #include "config.h" @@ -42,7 +42,7 @@ uudecode(const char *bufcoded) */ bufin = (const unsigned char *) bufcoded; while (pr2six[*(bufin++)] <= 63); - nprbytes = (char *) bufin - bufcoded - 1; + nprbytes = (const char *) bufin - bufcoded - 1; nbytesdecoded = ((nprbytes + 3) / 4) * 3; bufplain = xmalloc(nbytesdecoded + 1); diff --git a/src/ACL.h b/src/ACL.h index fb5cbe0844..b7909cc689 100644 --- a/src/ACL.h +++ b/src/ACL.h @@ -1,6 +1,6 @@ /* - * $Id: ACL.h,v 1.11 2003/10/20 12:33:01 robertc Exp $ + * $Id: ACL.h,v 1.12 2004/08/30 05:12:30 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -135,8 +135,7 @@ class ACLList { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLList); ACLList(); void negated(bool isNegated); @@ -144,10 +143,9 @@ public: int op; ACL *_acl; ACLList *next; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(ACLList) + typedef ACLList acl_list; #endif /* SQUID_ACL_H */ diff --git a/src/ACLARP.cc b/src/ACLARP.cc index 86cbd9fd53..10e42042e6 100644 --- a/src/ACLARP.cc +++ b/src/ACLARP.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLARP.cc,v 1.4 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLARP.cc,v 1.5 2004/08/30 05:12:30 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -84,25 +84,6 @@ ACLARP::ACLARP (ACLARP const & old) : data (NULL), class_ (old.class_) assert (!old.data); } -MemPool (*ACLARP::Pool)(NULL); -void * -ACLARP::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLARP)); - - if (!Pool) - Pool = memPoolCreate("ACLARP", sizeof (ACLARP)); - - return memPoolAlloc(Pool); -} - -void -ACLARP::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLARP::~ACLARP() { if (data) diff --git a/src/ACLARP.h b/src/ACLARP.h index 6e6a774203..050e464380 100644 --- a/src/ACLARP.h +++ b/src/ACLARP.h @@ -1,6 +1,6 @@ /* - * $Id: ACLARP.h,v 1.2 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLARP.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -48,8 +48,7 @@ class ACLARP : public ACL { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLARP); ACLARP(char const *); ACLARP(ACLARP const &); @@ -64,11 +63,12 @@ public: virtual bool valid () const; protected: - static MemPool *Pool; static Prototype RegistryProtoype; static ACLARP RegistryEntry_; SplayNode *data; char const *class_; }; +MEMPROXY_CLASS_INLINE(ACLARP) + #endif /* SQUID_ACLARP_H */ diff --git a/src/ACLASN.h b/src/ACLASN.h index b848ed4c98..a09325ce11 100644 --- a/src/ACLASN.h +++ b/src/ACLASN.h @@ -1,6 +1,6 @@ /* - * $Id: ACLASN.h,v 1.4 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLASN.h,v 1.5 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -48,8 +48,7 @@ class ACLASN : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLASN); virtual ~ACLASN(); @@ -60,7 +59,6 @@ public: virtual void prepareForUse(); private: - static MemPool *Pool; static ACL::Prototype SourceRegistryProtoype; static ACLStrategised SourceRegistryEntry_; static ACL::Prototype DestinationRegistryProtoype; @@ -68,4 +66,6 @@ private: List *data; }; +MEMPROXY_CLASS_INLINE(ACLASN) + #endif /* SQUID_ACLASN_H */ diff --git a/src/ACLCertificateData.cc b/src/ACLCertificateData.cc index c605fe4034..1c04cb5c22 100644 --- a/src/ACLCertificateData.cc +++ b/src/ACLCertificateData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLCertificateData.cc,v 1.6 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLCertificateData.cc,v 1.7 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -39,25 +39,6 @@ #include "authenticate.h" #include "ACLChecklist.h" -MemPool (*ACLCertificateData::Pool)(NULL); -void * -ACLCertificateData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLCertificateData)); - - if (!Pool) - Pool = memPoolCreate("ACLCertificateData", sizeof (ACLCertificateData)); - - return memPoolAlloc(Pool); -} - -void -ACLCertificateData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLCertificateData::ACLCertificateData(SSLGETATTRIBUTE *sslStrategy) : attribute (NULL), values (), sslAttributeCall (sslStrategy) {} diff --git a/src/ACLCertificateData.h b/src/ACLCertificateData.h index e0e62a1b1b..bf98c0f534 100644 --- a/src/ACLCertificateData.h +++ b/src/ACLCertificateData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLCertificateData.h,v 1.5 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLCertificateData.h,v 1.6 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -45,8 +45,7 @@ class ACLCertificateData : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLCertificateData); ACLCertificateData(SSLGETATTRIBUTE *); ACLCertificateData(ACLCertificateData const &); @@ -61,8 +60,9 @@ public: ACLStringData values; private: - static MemPool *Pool; SSLGETATTRIBUTE *sslAttributeCall; }; +MEMPROXY_CLASS_INLINE(ACLCertificateData) + #endif /* SQUID_ACLCERTIFICATEDATA_H */ diff --git a/src/ACLDestinationDomain.cc b/src/ACLDestinationDomain.cc index 48be437bd4..32b30072e9 100644 --- a/src/ACLDestinationDomain.cc +++ b/src/ACLDestinationDomain.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLDestinationDomain.cc,v 1.6 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLDestinationDomain.cc,v 1.7 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -42,25 +42,6 @@ #include "ACLDomainData.h" #include "HttpRequest.h" -MemPool (*ACLDestinationDomain::Pool)(NULL); -void * -ACLDestinationDomain::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLDestinationDomain)); - - if (!Pool) - Pool = memPoolCreate("ACLDestinationDomain", sizeof (ACLDestinationDomain)); - - return memPoolAlloc(Pool); -} - -void -ACLDestinationDomain::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLDestinationDomain::~ACLDestinationDomain() { delete data; diff --git a/src/ACLDestinationDomain.h b/src/ACLDestinationDomain.h index 5676425b59..9cc1c5a616 100644 --- a/src/ACLDestinationDomain.h +++ b/src/ACLDestinationDomain.h @@ -1,6 +1,6 @@ /* - * $Id: ACLDestinationDomain.h,v 1.5 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLDestinationDomain.h,v 1.6 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -55,8 +55,7 @@ class ACLDestinationDomain : public ACL { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLDestinationDomain); ~ACLDestinationDomain(); ACLDestinationDomain(ACLData *, char const *); @@ -73,7 +72,6 @@ public: virtual ACL *clone()const; private: - static MemPool *Pool; static Prototype LiteralRegistryProtoype; static Prototype LegacyRegistryProtoype; static ACLDestinationDomain LiteralRegistryEntry_; @@ -83,4 +81,6 @@ private: char const *type_; }; +MEMPROXY_CLASS_INLINE(ACLDestinationDomain) + #endif /* SQUID_ACLDESTINATIONDOMAIN_H */ diff --git a/src/ACLDestinationIP.cc b/src/ACLDestinationIP.cc index f497cdf58b..d808144fe5 100644 --- a/src/ACLDestinationIP.cc +++ b/src/ACLDestinationIP.cc @@ -38,25 +38,6 @@ #include "ACLChecklist.h" #include "HttpRequest.h" -MemPool (*ACLDestinationIP::Pool)(NULL); -void * -ACLDestinationIP::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLDestinationIP)); - - if (!Pool) - Pool = memPoolCreate("ACLDestinationIP", sizeof (ACLDestinationIP)); - - return memPoolAlloc(Pool); -} - -void -ACLDestinationIP::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - char const * ACLDestinationIP::typeString() const { diff --git a/src/ACLDestinationIP.h b/src/ACLDestinationIP.h index 6ee0dc56bf..55b956eb0f 100644 --- a/src/ACLDestinationIP.h +++ b/src/ACLDestinationIP.h @@ -54,8 +54,7 @@ class ACLDestinationIP : public ACLIP { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLDestinationIP); virtual char const *typeString() const; virtual int match(ACLChecklist *checklist); @@ -64,9 +63,10 @@ public: virtual ACL *clone()const; private: - static MemPool *Pool; static Prototype RegistryProtoype; static ACLDestinationIP RegistryEntry_; }; +MEMPROXY_CLASS_INLINE(ACLDestinationIP) + #endif /* SQUID_ACLDESTINATIONIP_H */ diff --git a/src/ACLDomainData.cc b/src/ACLDomainData.cc index 186138a452..499a417862 100644 --- a/src/ACLDomainData.cc +++ b/src/ACLDomainData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLDomainData.cc,v 1.5 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLDomainData.cc,v 1.6 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -39,25 +39,6 @@ #include "authenticate.h" #include "ACLChecklist.h" -MemPool (*ACLDomainData::Pool)(NULL); -void * -ACLDomainData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLDomainData)); - - if (!Pool) - Pool = memPoolCreate("ACLDomainData", sizeof (ACLDomainData)); - - return memPoolAlloc(Pool); -} - -void -ACLDomainData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - template inline void xRefFree(T &thing) diff --git a/src/ACLDomainData.h b/src/ACLDomainData.h index c90ac8157a..23b531ef04 100644 --- a/src/ACLDomainData.h +++ b/src/ACLDomainData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLDomainData.h,v 1.4 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLDomainData.h,v 1.5 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -43,8 +43,7 @@ class ACLDomainData : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLDomainData); virtual ~ACLDomainData(); bool match(char const *); @@ -53,9 +52,8 @@ public: virtual ACLData *clone() const; SplayNode *domains; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(ACLDomainData) + #endif /* SQUID_ACLDOMAINDATA_H */ diff --git a/src/ACLExtUser.cc b/src/ACLExtUser.cc index a38e8ebcaa..01adcd77bd 100644 --- a/src/ACLExtUser.cc +++ b/src/ACLExtUser.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLExtUser.cc,v 1.4 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLExtUser.cc,v 1.5 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -43,25 +43,6 @@ #include "client_side.h" #include "HttpRequest.h" -MemPool (*ACLExtUser::Pool)(NULL); -void * -ACLExtUser::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLExtUser)); - - if (!Pool) - Pool = memPoolCreate("ACLExtUser", sizeof (ACLExtUser)); - - return memPoolAlloc(Pool); -} - -void -ACLExtUser::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLExtUser::~ACLExtUser() { delete data; diff --git a/src/ACLExtUser.h b/src/ACLExtUser.h index 34c9de51f2..44482e1fe4 100644 --- a/src/ACLExtUser.h +++ b/src/ACLExtUser.h @@ -1,6 +1,6 @@ /* - * $Id: ACLExtUser.h,v 1.2 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLExtUser.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -43,8 +43,7 @@ class ACLExtUser : public ACL { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLExtUser); ACLExtUser(ACLData *newData, char const *); ACLExtUser (ACLExtUser const &old); @@ -61,7 +60,6 @@ public: virtual ACL *clone()const; private: - static MemPool *Pool; static Prototype UserRegistryProtoype; static ACLExtUser UserRegistryEntry_; static Prototype RegexRegistryProtoype; @@ -70,4 +68,6 @@ private: char const *type_; }; +MEMPROXY_CLASS_INLINE(ACLExtUser) + #endif /* SQUID_ACLIDENT_H */ diff --git a/src/ACLIP.cc b/src/ACLIP.cc index c2c7a025cd..aa807c4c25 100644 --- a/src/ACLIP.cc +++ b/src/ACLIP.cc @@ -399,25 +399,6 @@ ACLIP::match(struct in_addr &clientip) return !splayLastResult; } -MemPool (*acl_ip_data::Pool)(NULL); -void * -acl_ip_data::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (acl_ip_data)); - - if (!Pool) - Pool = memPoolCreate("acl_ip_data", sizeof (acl_ip_data)); - - return memPoolAlloc(Pool); -} - -void -acl_ip_data::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - acl_ip_data::acl_ip_data () :addr1(any_addr), addr2(any_addr), mask (any_addr), next (NULL) {} acl_ip_data::acl_ip_data (struct in_addr const &anAddress1, struct in_addr const &anAddress2, struct in_addr const &aMask, acl_ip_data *aNext) : addr1(anAddress1), addr2(anAddress2), mask(aMask), next(aNext){} diff --git a/src/ACLIP.h b/src/ACLIP.h index 83293c331c..dc447a3419 100644 --- a/src/ACLIP.h +++ b/src/ACLIP.h @@ -42,8 +42,7 @@ class acl_ip_data { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(acl_ip_data); static acl_ip_data *FactoryParse(char const *); static int NetworkCompare(acl_ip_data * const & a, acl_ip_data * const &b); @@ -62,9 +61,10 @@ public: private: static bool DecodeAddress(const char *asc, struct in_addr *addr, struct in_addr *mask); - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(acl_ip_data) + class ACLIP : public ACL { diff --git a/src/ACLIdent.cc b/src/ACLIdent.cc index 44b72a8f7f..835594428c 100644 --- a/src/ACLIdent.cc +++ b/src/ACLIdent.cc @@ -42,25 +42,6 @@ #include "ACLUserData.h" #include "client_side.h" -MemPool (*ACLIdent::Pool)(NULL); -void * -ACLIdent::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLIdent)); - - if (!Pool) - Pool = memPoolCreate("ACLIdent", sizeof (ACLIdent)); - - return memPoolAlloc(Pool); -} - -void -ACLIdent::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLIdent::~ACLIdent() { delete data; diff --git a/src/ACLIdent.h b/src/ACLIdent.h index e0dfe65b1f..cb035a4c7f 100644 --- a/src/ACLIdent.h +++ b/src/ACLIdent.h @@ -55,8 +55,7 @@ class ACLIdent : public ACL { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLIdent); ACLIdent(ACLData *newData, char const *); ACLIdent (ACLIdent const &old); @@ -73,7 +72,6 @@ public: virtual ACL *clone()const; private: - static MemPool *Pool; static Prototype UserRegistryProtoype; static ACLIdent UserRegistryEntry_; static Prototype RegexRegistryProtoype; @@ -82,4 +80,6 @@ private: char const *type_; }; +MEMPROXY_CLASS_INLINE(ACLIdent) + #endif /* SQUID_ACLIDENT_H */ diff --git a/src/ACLMaxConnection.cc b/src/ACLMaxConnection.cc index 2788c7cf5a..e54726c3bc 100644 --- a/src/ACLMaxConnection.cc +++ b/src/ACLMaxConnection.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLMaxConnection.cc,v 1.3 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLMaxConnection.cc,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -53,25 +53,6 @@ ACLMaxConnection::ACLMaxConnection (char const *theClass) : class_ (theClass), l ACLMaxConnection::ACLMaxConnection (ACLMaxConnection const & old) :class_ (old.class_), limit (old.limit) {} -MemPool (*ACLMaxConnection::Pool)(NULL); -void * -ACLMaxConnection::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLMaxConnection)); - - if (!Pool) - Pool = memPoolCreate("ACLMaxConnection", sizeof (ACLMaxConnection)); - - return memPoolAlloc(Pool); -} - -void -ACLMaxConnection::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLMaxConnection::~ACLMaxConnection() {} diff --git a/src/ACLMaxConnection.h b/src/ACLMaxConnection.h index 066ab042e4..384df07b41 100644 --- a/src/ACLMaxConnection.h +++ b/src/ACLMaxConnection.h @@ -1,6 +1,6 @@ /* - * $Id: ACLMaxConnection.h,v 1.2 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLMaxConnection.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -42,8 +42,7 @@ class ACLMaxConnection : public ACL { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLMaxConnection); ACLMaxConnection(char const *); ACLMaxConnection(ACLMaxConnection const &); @@ -59,11 +58,12 @@ public: virtual void prepareForUse(); protected: - static MemPool *Pool; static Prototype RegistryProtoype; static ACLMaxConnection RegistryEntry_; char const *class_; int limit; }; +MEMPROXY_CLASS_INLINE(ACLMaxConnection) + #endif /* SQUID_ACLMAXCONNECTION_H */ diff --git a/src/ACLMaxUserIP.cc b/src/ACLMaxUserIP.cc index 62226694b4..a8b5565e7a 100644 --- a/src/ACLMaxUserIP.cc +++ b/src/ACLMaxUserIP.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLMaxUserIP.cc,v 1.5 2004/08/30 03:28:56 robertc Exp $ + * $Id: ACLMaxUserIP.cc,v 1.6 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -55,25 +55,6 @@ ACLMaxUserIP::ACLMaxUserIP (char const *theClass) : class_ (theClass), maximum(0 ACLMaxUserIP::ACLMaxUserIP (ACLMaxUserIP const & old) :class_ (old.class_), maximum (old.maximum), flags (old.flags) {} -MemPool (*ACLMaxUserIP::Pool)(NULL); -void * -ACLMaxUserIP::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLMaxUserIP)); - - if (!Pool) - Pool = memPoolCreate("ACLMaxUserIP", sizeof (ACLMaxUserIP)); - - return memPoolAlloc(Pool); -} - -void -ACLMaxUserIP::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLMaxUserIP::~ACLMaxUserIP() {} diff --git a/src/ACLMaxUserIP.h b/src/ACLMaxUserIP.h index 353f35ebff..ddc5838219 100644 --- a/src/ACLMaxUserIP.h +++ b/src/ACLMaxUserIP.h @@ -1,6 +1,6 @@ /* - * $Id: ACLMaxUserIP.h,v 1.3 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLMaxUserIP.h,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -42,8 +42,7 @@ class ACLMaxUserIP : public ACL { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLMaxUserIP); ACLMaxUserIP(char const *); ACLMaxUserIP(ACLMaxUserIP const &); @@ -59,7 +58,6 @@ public: virtual bool requiresRequest() const {return true;} private: - static MemPool *Pool; static Prototype RegistryProtoype; static ACLMaxUserIP RegistryEntry_; @@ -78,4 +76,6 @@ unsigned int strict: flags; }; +MEMPROXY_CLASS_INLINE(ACLMaxUserIP) + #endif /* SQUID_ACLMAXUSERIP_H */ diff --git a/src/ACLMethodData.cc b/src/ACLMethodData.cc index 048e2d17c7..d355199148 100644 --- a/src/ACLMethodData.cc +++ b/src/ACLMethodData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLMethodData.cc,v 1.4 2003/10/20 12:33:01 robertc Exp $ + * $Id: ACLMethodData.cc,v 1.5 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -38,25 +38,6 @@ #include "ACLMethodData.h" #include "ACLChecklist.h" -MemPool (*ACLMethodData::Pool)(NULL); -void * -ACLMethodData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLMethodData)); - - if (!Pool) - Pool = memPoolCreate("ACLMethodData", sizeof (ACLMethodData)); - - return memPoolAlloc(Pool); -} - -void -ACLMethodData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLMethodData::ACLMethodData() : values (NULL) {} diff --git a/src/ACLMethodData.h b/src/ACLMethodData.h index 97ec7d9fe8..24ad5d540e 100644 --- a/src/ACLMethodData.h +++ b/src/ACLMethodData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLMethodData.h,v 1.2 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLMethodData.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -43,8 +43,7 @@ class ACLMethodData : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLMethodData); ACLMethodData(); ACLMethodData(ACLMethodData const &); @@ -56,9 +55,8 @@ public: virtual ACLData *clone() const; List *values; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(ACLMethodData) + #endif /* SQUID_ACLMETHODDATA_H */ diff --git a/src/ACLMyIP.cc b/src/ACLMyIP.cc index 1306b0e2c6..bd8b449c9d 100644 --- a/src/ACLMyIP.cc +++ b/src/ACLMyIP.cc @@ -37,25 +37,6 @@ #include "ACLMyIP.h" #include "ACLChecklist.h" -MemPool (*ACLMyIP::Pool)(NULL); -void * -ACLMyIP::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLMyIP)); - - if (!Pool) - Pool = memPoolCreate("ACLMyIP", sizeof (ACLMyIP)); - - return memPoolAlloc(Pool); -} - -void -ACLMyIP::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - char const * ACLMyIP::typeString() const { diff --git a/src/ACLMyIP.h b/src/ACLMyIP.h index dfe289eb05..ae7c3145f9 100644 --- a/src/ACLMyIP.h +++ b/src/ACLMyIP.h @@ -41,8 +41,7 @@ class ACLMyIP : public ACLIP { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLMyIP); static ACLMyIP const &RegistryEntry(); virtual char const *typeString() const; @@ -50,9 +49,10 @@ public: virtual ACL *clone()const; private: - static MemPool *Pool; static Prototype RegistryProtoype; static ACLMyIP RegistryEntry_; }; +MEMPROXY_CLASS_INLINE(ACLMyIP) + #endif /* SQUID_ACLMYIP_H */ diff --git a/src/ACLProtocolData.cc b/src/ACLProtocolData.cc index 3b9907ea02..60486f7772 100644 --- a/src/ACLProtocolData.cc +++ b/src/ACLProtocolData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLProtocolData.cc,v 1.4 2003/10/20 12:33:01 robertc Exp $ + * $Id: ACLProtocolData.cc,v 1.5 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -38,25 +38,6 @@ #include "ACLProtocolData.h" #include "ACLChecklist.h" -MemPool (*ACLProtocolData::Pool)(NULL); -void * -ACLProtocolData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLProtocolData)); - - if (!Pool) - Pool = memPoolCreate("ACLProtocolData", sizeof (ACLProtocolData)); - - return memPoolAlloc(Pool); -} - -void -ACLProtocolData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLProtocolData::ACLProtocolData() : values (NULL) {} diff --git a/src/ACLProtocolData.h b/src/ACLProtocolData.h index 23db7afee0..0414866468 100644 --- a/src/ACLProtocolData.h +++ b/src/ACLProtocolData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLProtocolData.h,v 1.2 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLProtocolData.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -43,8 +43,7 @@ class ACLProtocolData : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLProtocolData); ACLProtocolData(); ACLProtocolData(ACLProtocolData const &); @@ -56,9 +55,8 @@ public: virtual ACLData *clone() const; List *values; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(ACLProtocolData); + #endif /* SQUID_ACLPROTOCOLDATA_H */ diff --git a/src/ACLProxyAuth.cc b/src/ACLProxyAuth.cc index c3a85da434..40d2bd1faf 100644 --- a/src/ACLProxyAuth.cc +++ b/src/ACLProxyAuth.cc @@ -45,25 +45,6 @@ #include "AuthUser.h" #include "AuthUserRequest.h" -MemPool (*ACLProxyAuth::Pool)(NULL); -void * -ACLProxyAuth::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLProxyAuth)); - - if (!Pool) - Pool = memPoolCreate("ACLProxyAuth", sizeof (ACLProxyAuth)); - - return memPoolAlloc(Pool); -} - -void -ACLProxyAuth::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLProxyAuth::~ACLProxyAuth() { delete data; diff --git a/src/ACLProxyAuth.h b/src/ACLProxyAuth.h index 53d663d4b6..bb5ee60561 100644 --- a/src/ACLProxyAuth.h +++ b/src/ACLProxyAuth.h @@ -66,8 +66,7 @@ class ACLProxyAuth : public ACL { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLProxyAuth); ~ACLProxyAuth(); ACLProxyAuth(ACLData *, char const *); @@ -87,7 +86,6 @@ public: virtual int matchForCache(ACLChecklist *checklist); private: - static MemPool *Pool; static Prototype UserRegistryProtoype; static ACLProxyAuth UserRegistryEntry_; static Prototype RegexRegistryProtoype; @@ -98,4 +96,6 @@ private: char const *type_; }; +MEMPROXY_CLASS_INLINE(ACLProxyAuth) + #endif /* SQUID_ACLPROXYAUTH_H */ diff --git a/src/ACLRegexData.cc b/src/ACLRegexData.cc index b1dedee817..15ac98103c 100644 --- a/src/ACLRegexData.cc +++ b/src/ACLRegexData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLRegexData.cc,v 1.6 2003/08/04 22:14:38 robertc Exp $ + * $Id: ACLRegexData.cc,v 1.7 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -40,25 +40,6 @@ #include "ACLChecklist.h" #include "ACL.h" -MemPool (*ACLRegexData::Pool)(NULL); -void * -ACLRegexData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLRegexData)); - - if (!Pool) - Pool = memPoolCreate("ACLRegexData", sizeof (ACLRegexData)); - - return memPoolAlloc(Pool); -} - -void -ACLRegexData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - static void aclDestroyRegexList(relist * data); void aclDestroyRegexList(relist * data) diff --git a/src/ACLRegexData.h b/src/ACLRegexData.h index ca84ffdd51..a9716c7109 100644 --- a/src/ACLRegexData.h +++ b/src/ACLRegexData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLRegexData.h,v 1.4 2003/08/04 22:14:40 robertc Exp $ + * $Id: ACLRegexData.h,v 1.5 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -41,8 +41,7 @@ class ACLRegexData : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLRegexData); virtual ~ACLRegexData(); virtual bool match(char const *user); @@ -51,8 +50,9 @@ public: virtual ACLData *clone() const; private: - static MemPool *Pool; relist *data; }; +MEMPROXY_CLASS_INLINE(ACLRegexData) + #endif /* SQUID_ACLREGEXDATA_H */ diff --git a/src/ACLSourceIP.cc b/src/ACLSourceIP.cc index 283bd8ba6e..1ccf86e815 100644 --- a/src/ACLSourceIP.cc +++ b/src/ACLSourceIP.cc @@ -37,25 +37,6 @@ #include "ACLSourceIP.h" #include "ACLChecklist.h" -MemPool (*ACLSourceIP::Pool)(NULL); -void * -ACLSourceIP::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLSourceIP)); - - if (!Pool) - Pool = memPoolCreate("ACLSourceIP", sizeof (ACLSourceIP)); - - return memPoolAlloc(Pool); -} - -void -ACLSourceIP::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - char const * ACLSourceIP::typeString() const { diff --git a/src/ACLSourceIP.h b/src/ACLSourceIP.h index 9f3690c049..e1e21cbe7a 100644 --- a/src/ACLSourceIP.h +++ b/src/ACLSourceIP.h @@ -41,17 +41,17 @@ class ACLSourceIP : public ACLIP { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLSourceIP); virtual char const *typeString() const; virtual int match(ACLChecklist *checklist); virtual ACL *clone()const; private: - static MemPool *Pool; static Prototype RegistryProtoype; static ACLSourceIP RegistryEntry_; }; +MEMPROXY_CLASS_INLINE(ACLSourceIP) + #endif /* SQUID_ACLSOURCEIP_H */ diff --git a/src/ACLStrategised.h b/src/ACLStrategised.h index c98ddfd4e1..f672e91e02 100644 --- a/src/ACLStrategised.h +++ b/src/ACLStrategised.h @@ -1,6 +1,6 @@ /* - * $Id: ACLStrategised.h,v 1.6 2003/08/10 09:53:49 robertc Exp $ + * $Id: ACLStrategised.h,v 1.7 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -67,7 +67,7 @@ public: virtual ACL *clone()const; private: - static MemPool *Pool; + static MemAllocator *Pool; ACLData *data; char const *type_; ACLStrategy *matcher; @@ -76,7 +76,7 @@ private: /* implementation follows */ template -MemPool *ACLStrategised::Pool = NULL; +MemAllocator *ACLStrategised::Pool = NULL; template void * @@ -86,16 +86,16 @@ ACLStrategised::operator new (size_t byteCount) assert (byteCount == sizeof (ACLStrategised)); if (!Pool) - Pool = memPoolCreate("ACLStrategised", sizeof (ACLStrategised)); + Pool = MemPools::GetInstance().create("ACLStrategised", sizeof (ACLStrategised)); - return memPoolAlloc(Pool); + return Pool->alloc(); } template void ACLStrategised::operator delete (void *address) { - memPoolFree (Pool, address); + Pool->free(address); } template diff --git a/src/ACLStringData.cc b/src/ACLStringData.cc index 99ad86b27a..9afa523449 100644 --- a/src/ACLStringData.cc +++ b/src/ACLStringData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLStringData.cc,v 1.4 2003/08/10 01:01:22 robertc Exp $ + * $Id: ACLStringData.cc,v 1.5 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -38,24 +38,6 @@ #include "ACLStringData.h" #include "ACLChecklist.h" -MemPool (*ACLStringData::Pool)(NULL); -void * -ACLStringData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLStringData)); - - if (!Pool) - Pool = memPoolCreate("ACLStringData", sizeof (ACLStringData)); - - return memPoolAlloc(Pool); -} - -void -ACLStringData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} ACLStringData::ACLStringData() : values (NULL) {} diff --git a/src/ACLStringData.h b/src/ACLStringData.h index 9492e5972c..33426e6b36 100644 --- a/src/ACLStringData.h +++ b/src/ACLStringData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLStringData.h,v 1.2 2003/08/04 22:14:40 robertc Exp $ + * $Id: ACLStringData.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -39,12 +39,12 @@ #include "ACL.h" #include "ACLData.h" + class ACLStringData : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLStringData); ACLStringData(); ACLStringData(ACLStringData const &); @@ -56,9 +56,10 @@ public: virtual ACLData *clone() const; SplayNode *values; - -private: - static MemPool *Pool; }; +/* TODO move into .cci files */ + +MEMPROXY_CLASS_INLINE(ACLStringData); + #endif /* SQUID_ACLSTRINGDATA_H */ diff --git a/src/ACLTimeData.cc b/src/ACLTimeData.cc index 2cf21f0ecf..979795506c 100644 --- a/src/ACLTimeData.cc +++ b/src/ACLTimeData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLTimeData.cc,v 1.4 2003/08/04 22:14:40 robertc Exp $ + * $Id: ACLTimeData.cc,v 1.5 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -39,25 +39,6 @@ #include "authenticate.h" #include "ACLChecklist.h" -MemPool (*ACLTimeData::Pool)(NULL); -void * -ACLTimeData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLTimeData)); - - if (!Pool) - Pool = memPoolCreate("ACLTimeData", sizeof (ACLTimeData)); - - return memPoolAlloc(Pool); -} - -void -ACLTimeData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLTimeData::ACLTimeData () : weekbits (0), start (0), stop (0), next (NULL) {} ACLTimeData::ACLTimeData(ACLTimeData const &old) : weekbits(old.weekbits), start (old.start), stop (old.stop), next (NULL) diff --git a/src/ACLTimeData.h b/src/ACLTimeData.h index 2cb883af6b..53a1c6048e 100644 --- a/src/ACLTimeData.h +++ b/src/ACLTimeData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLTimeData.h,v 1.3 2003/08/04 22:14:40 robertc Exp $ + * $Id: ACLTimeData.h,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -43,8 +43,7 @@ class ACLTimeData : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLTimeData); ACLTimeData(); ACLTimeData(ACLTimeData const &); @@ -56,11 +55,12 @@ public: virtual ACLData *clone() const; private: - static MemPool *Pool; int weekbits; int start; int stop; ACLTimeData *next; }; +MEMPROXY_CLASS_INLINE(ACLTimeData) + #endif /* SQUID_ACLTIMEDATA_H */ diff --git a/src/ACLUserData.cc b/src/ACLUserData.cc index 1cac6a805b..822f5dcf82 100644 --- a/src/ACLUserData.cc +++ b/src/ACLUserData.cc @@ -39,25 +39,6 @@ #include "authenticate.h" #include "ACLChecklist.h" -MemPool (*ACLUserData::Pool)(NULL); -void * -ACLUserData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLUserData)); - - if (!Pool) - Pool = memPoolCreate("ACLUserData", sizeof (ACLUserData)); - - return memPoolAlloc(Pool); -} - -void -ACLUserData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - template inline void xRefFree(T &thing) diff --git a/src/ACLUserData.h b/src/ACLUserData.h index 34cb833ba1..c5354648be 100644 --- a/src/ACLUserData.h +++ b/src/ACLUserData.h @@ -43,8 +43,7 @@ class ACLUserData : public ACLData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLUserData); virtual ~ACLUserData(); bool match(char const *user); @@ -65,9 +64,8 @@ unsigned int required: } flags; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(ACLUserData) + #endif /* SQUID_ACLUSERDATA_H */ diff --git a/src/ESI.cc b/src/ESI.cc index d74f8b7770..7124f8b9ab 100644 --- a/src/ESI.cc +++ b/src/ESI.cc @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.7 2004/08/15 17:42:37 robertc Exp $ + * $Id: ESI.cc,v 1.8 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -97,8 +97,7 @@ typedef ESIContext::esiKick_t esiKick_t; struct esiComment : public ESIElement { - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(esiComment); ~esiComment(); esiComment(); Pointer makeCacheable() const; @@ -106,16 +105,11 @@ struct esiComment : public ESIElement void render(ESISegment::Pointer); void finish(); - -private: - static MemPool *pool; }; -MemPool * esiComment::pool = NULL; - +MEMPROXY_CLASS_INLINE(esiComment) #include "ESILiteral.h" -MemPool *esiLiteral::pool = NULL; #include "ESISequence.h" @@ -147,8 +141,7 @@ static ESIElement * esiRemoveNew(void); struct esiTry : public ESIElement { - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(esiTry); esiTry(esiTreeParentPtr aParent); ~esiTry(); @@ -184,7 +177,6 @@ int exceptfailed: void finish(); private: - static MemPool *Pool; void notifyParent(); esiTreeParentPtr parent; ESISegment::Pointer exceptbuffer; @@ -192,7 +184,7 @@ private: esiProcessResult_t bestAttemptRV() const; }; -MemPool *esiTry::Pool = NULL; +MEMPROXY_CLASS_INLINE(esiTry) #include "ESIVar.h" @@ -200,8 +192,7 @@ MemPool *esiTry::Pool = NULL; struct esiChoose : public ESIElement { - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(esiChoose); esiChoose(esiTreeParentPtr); ~esiChoose(); @@ -224,21 +215,19 @@ struct esiChoose : public ESIElement void finish(); private: - static MemPool *Pool; esiChoose(esiChoose const &); esiTreeParentPtr parent; void checkValidSource (ESIElement::Pointer source) const; void selectElement(); }; -MemPool *esiChoose::Pool = NULL; +MEMPROXY_CLASS_INLINE(esiChoose) /* esiWhen */ struct esiWhen : public esiSequence { - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(esiWhen); esiWhen(esiTreeParentPtr aParent, int attributes, const char **attr, ESIVarState *); ~esiWhen(); Pointer makeCacheable() const; @@ -249,7 +238,6 @@ struct esiWhen : public esiSequence void setTestResult(bool aBool) {testValue = aBool;} private: - static MemPool *Pool; esiWhen (esiWhen const &); bool testValue; char const *unevaluatedExpression; @@ -257,7 +245,7 @@ private: void evaluate(); }; -MemPool *esiWhen::Pool = NULL; +MEMPROXY_CLASS_INLINE(esiWhen) /* esiOtherwise */ @@ -1509,23 +1497,6 @@ esiComment::~esiComment() debug (86,5)("esiComment::~esiComment %p\n", this); } -void * -esiComment::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiComment)); - - if (!pool) - pool = memPoolCreate ("esiComment", sizeof (esiComment)); - - return memPoolAlloc(pool); -} - -void -esiComment::operator delete (void *address) -{ - memPoolFree (pool, address); -} - esiComment::esiComment() {} @@ -1555,23 +1526,6 @@ esiComment::makeUsable(esiTreeParentPtr, ESIVarState &) const } /* esiLiteral */ -void * -esiLiteral::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiLiteral)); - - if (!pool) - pool = memPoolCreate ("esiLiteral", sizeof (esiLiteral)); - - return memPoolAlloc (pool); -} - -void -esiLiteral::operator delete (void *address) -{ - memPoolFree (pool, address); -} - esiLiteral::~esiLiteral() { debug (86, 5) ("esiLiteral::~esiLiteral: %p\n", this); @@ -1748,23 +1702,6 @@ esiTry::~esiTry() debug (86,5)("esiTry::~esiTry %p\n", this); } -void * -esiTry::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiTry)); - - if (!Pool) - Pool = memPoolCreate ("esiTry", sizeof(esiTry)); - - return memPoolAlloc (Pool); -} - -void -esiTry::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - esiTry::esiTry(esiTreeParentPtr aParent) : parent (aParent) , exceptbuffer(NULL) {} @@ -2082,23 +2019,6 @@ esiChoose::~esiChoose() debug (86,5)("esiChoose::~esiChoose %p\n", this); } -void * -esiChoose::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiChoose)); - - if (!Pool) - Pool = memPoolCreate ("esiChoose", sizeof(esiChoose)); - - return memPoolAlloc (Pool); -} - -void -esiChoose::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - esiChoose::esiChoose(esiTreeParentPtr aParent) : elements (), chosenelement (-1),parent (aParent) {} @@ -2400,23 +2320,6 @@ ElementList::size() const } /* esiWhen */ -void * -esiWhen::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiWhen)); - - if (!Pool) - Pool = memPoolCreate("esiWhen", sizeof(esiWhen)); - - return memPoolAlloc(Pool); -} - -void -esiWhen::operator delete (void *address) -{ - memPoolFree(Pool, address); -} - esiWhen::esiWhen (esiTreeParentPtr aParent, int attrcount, const char **attr,ESIVarState *aVar) : esiSequence (aParent) { varState = NULL; diff --git a/src/ESIAssign.cc b/src/ESIAssign.cc index 3a5fdc8152..badf8fcfbb 100644 --- a/src/ESIAssign.cc +++ b/src/ESIAssign.cc @@ -1,6 +1,6 @@ /* - * $Id: ESIAssign.cc,v 1.2 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESIAssign.cc,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -38,25 +38,6 @@ #include "ESIContext.h" #include "ESISequence.h" -MemPool *ESIAssign::Pool = NULL; - -void * -ESIAssign::operator new (size_t byteCount) -{ - assert (byteCount == sizeof (ESIAssign)); - - if (!Pool) - Pool = memPoolCreate ("ESIAssign", sizeof (ESIAssign)); - - return memPoolAlloc(Pool); -} - -void -ESIAssign::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ESIAssign::~ESIAssign() { if (value) diff --git a/src/ESIAssign.h b/src/ESIAssign.h index fe9b7d45e1..74c53a7a6d 100644 --- a/src/ESIAssign.h +++ b/src/ESIAssign.h @@ -1,5 +1,5 @@ /* - * $Id: ESIAssign.h,v 1.2 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESIAssign.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -64,8 +64,7 @@ class ESIAssign : public ESIElement { public: - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(ESIAssign); ESIAssign (esiTreeParentPtr, int, const char **, ESIContext *); ESIAssign (ESIAssign const &); ESIAssign &operator=(ESIAssign const &); @@ -79,7 +78,6 @@ public: void finish(); private: - static MemPool *Pool; void evaluateVariable(); esiTreeParentPtr parent; ESIVarState *varState; @@ -89,4 +87,6 @@ private: String unevaluatedVariable; }; +MEMPROXY_CLASS_INLINE(ESIAssign) + #endif /* SQUID_ESIASSIGN_H */ diff --git a/src/ESIInclude.cc b/src/ESIInclude.cc index 6ee9b89bb7..19d51989f6 100644 --- a/src/ESIInclude.cc +++ b/src/ESIInclude.cc @@ -1,6 +1,6 @@ /* - * $Id: ESIInclude.cc,v 1.3 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESIInclude.cc,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -42,8 +42,6 @@ CBDATA_CLASS_INIT (ESIStreamContext); -MemPool *ESIInclude::Pool = NULL; - /* other */ static CSCB esiBufferRecipient; static CSD esiBufferDetach; @@ -278,23 +276,6 @@ ESIInclude::finish() parent = NULL; } -void * -ESIInclude::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (ESIInclude)); - - if (!Pool) - Pool = memPoolCreate ("ESIInclude", sizeof (ESIInclude)); - - return memPoolAlloc(Pool); -} - -void -ESIInclude::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ESIElement::Pointer ESIInclude::makeCacheable() const { diff --git a/src/ESIInclude.h b/src/ESIInclude.h index 621a337d96..2717155c35 100644 --- a/src/ESIInclude.h +++ b/src/ESIInclude.h @@ -1,5 +1,5 @@ /* - * $Id: ESIInclude.h,v 1.2 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESIInclude.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -69,8 +69,7 @@ class ESIInclude : public ESIElement { public: - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(ESIInclude); ESIInclude(esiTreeParentPtr, int attributes, const char **attr, ESIContext *); ~ESIInclude(); @@ -104,7 +103,6 @@ int finished: void finish(); private: - static MemPool *Pool; void Start (ESIStreamContext::Pointer, char const *, ESIVarState *); esiTreeParentPtr parent; void start(); @@ -115,4 +113,6 @@ private: void prepareRequestHeaders(HttpHeader &tempheaders, ESIVarState *vars); }; +MEMPROXY_CLASS_INLINE(ESIInclude) + #endif /* SQUID_ESIINCLUDE_H */ diff --git a/src/ESILiteral.h b/src/ESILiteral.h index 9a4ba939b6..071551c45c 100644 --- a/src/ESILiteral.h +++ b/src/ESILiteral.h @@ -1,5 +1,5 @@ /* - * $Id: ESILiteral.h,v 1.3 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESILiteral.h,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -44,8 +44,7 @@ class ESIContext; struct esiLiteral : public ESIElement { - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(esiLiteral); esiLiteral(ESISegment::Pointer); esiLiteral(ESIContext *, const char *s, int len); @@ -70,8 +69,9 @@ int donevars: void finish(); private: - static MemPool *pool; esiLiteral(esiLiteral const &); }; +MEMPROXY_CLASS_INLINE(esiLiteral) + #endif /* SQUID_ESILITERAL_H */ diff --git a/src/ESISequence.cc b/src/ESISequence.cc index bfda742099..9c4bbe1923 100644 --- a/src/ESISequence.cc +++ b/src/ESISequence.cc @@ -1,5 +1,5 @@ /* - * $Id: ESISequence.cc,v 1.3 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESISequence.cc,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -41,31 +41,11 @@ class esiExcept; -MemPool *esiSequence::Pool = NULL; - esiSequence::~esiSequence () { debug (86,5)("esiSequence::~esiSequence %p\n", this); } -void * -esiSequence::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiSequence)); - - if (!Pool) - Pool = memPoolCreate ("esiSequence", sizeof (esiSequence)); - - return memPoolAlloc (Pool); -} - -void -esiSequence::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - - esiSequence::esiSequence(esiTreeParentPtr aParent, bool incrementalFlag) : elements(), parent (aParent), mayFail_(true), failed (false), provideIncrementalData (incrementalFlag), processing (false), processingResult (ESI_PROCESS_COMPLETE), nextElementToProcess_ (0) {} diff --git a/src/ESISequence.h b/src/ESISequence.h index 58a27785c0..167263a042 100644 --- a/src/ESISequence.h +++ b/src/ESISequence.h @@ -1,5 +1,5 @@ /* - * $Id: ESISequence.h,v 1.3 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESISequence.h,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -46,8 +46,7 @@ class esiSequence : public ESIElement { public: - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(esiSequence); esiSequence(esiTreeParentPtr, bool = false); ~esiSequence(); @@ -82,7 +81,6 @@ protected: esiTreeParentPtr parent; private: - static MemPool *Pool; int elementIndex (ESIElement::Pointer anElement) const; bool mayFail_; bool failed; @@ -97,4 +95,6 @@ private: void processStep(int dovars); }; +MEMPROXY_CLASS_INLINE(esiSequence) + #endif /* SQUID_ESISEQUENCE_H */ diff --git a/src/ExternalACL.h b/src/ExternalACL.h index 174ec5b0b4..dcc5ff5ac5 100644 --- a/src/ExternalACL.h +++ b/src/ExternalACL.h @@ -1,6 +1,6 @@ /* - * $Id: ExternalACL.h,v 1.5 2003/08/04 22:14:40 robertc Exp $ + * $Id: ExternalACL.h,v 1.6 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -58,8 +58,7 @@ class ACLExternal : public ACL { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(ACLExternal); static void ExternalAclLookup(ACLChecklist * ch, ACLExternal *, EAH * callback, void *callback_data); @@ -84,11 +83,12 @@ public: virtual bool valid () const; protected: - static MemPool *Pool; static Prototype RegistryProtoype; static ACLExternal RegistryEntry_; external_acl_data *data; char const *class_; }; +MEMPROXY_CLASS_INLINE(ACLExternal) + #endif /* SQUID_EXTERNALACL_H */ diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index 1e8d849a2a..1c52ae8a49 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrRange.cc,v 1.38 2003/09/29 10:24:00 robertc Exp $ + * $Id: HttpHdrRange.cc,v 1.39 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 64 HTTP Range Header * AUTHOR: Alex Rousskov @@ -69,25 +69,6 @@ ssize_t const HttpHdrRangeSpec::UnknownPosition = -1; * Range-Spec */ -MemPool *HttpHdrRangeSpec::Pool = NULL; - -void * -HttpHdrRangeSpec::operator new(size_t size) -{ - assert (size == sizeof (HttpHdrRangeSpec)); - - if (!Pool) - Pool = memPoolCreate ("HttpHdrRangeSpec", sizeof (HttpHdrRangeSpec)); - - return memPoolAlloc(Pool); -} - -void -HttpHdrRangeSpec::operator delete (void *spec) -{ - memPoolFree(Pool, spec); -} - HttpHdrRangeSpec::HttpHdrRangeSpec() : offset(UnknownPosition), length(UnknownPosition){} /* parses range-spec and returns new object on success */ @@ -245,25 +226,6 @@ HttpHdrRangeSpec::mergeWith(const HttpHdrRangeSpec * donor) * Range */ -MemPool *HttpHdrRange::Pool = NULL; - -void * -HttpHdrRange::operator new(size_t size) -{ - assert (size == sizeof (HttpHdrRange)); - - if (!Pool) - Pool = memPoolCreate ("HttpHdrRange", sizeof (HttpHdrRange)); - - return memPoolAlloc(Pool); -} - -void -HttpHdrRange::operator delete (void *address) -{ - memPoolFree(Pool, address); -} - HttpHdrRange::HttpHdrRange () : clen (HttpHdrRangeSpec::UnknownPosition) {} diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 91f573806c..49fcd7a466 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.95 2003/09/29 10:24:00 robertc Exp $ + * $Id: HttpHeader.cc,v 1.96 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -1480,25 +1480,6 @@ httpHeaderNameById(int id) return HeadersAttrs[id].name; } -MemPool (*HttpHeaderEntry::Pool)(NULL); -void * -HttpHeaderEntry::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (HttpHeaderEntry)); - - if (!Pool) - Pool = memPoolCreate("HttpHeaderEntry", sizeof (HttpHeaderEntry)); - - return memPoolAlloc(Pool); -} - -void -HttpHeaderEntry::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - int httpHeaderHasListMember(const HttpHeader * hdr, http_hdr_type id, const char *member, const char separator) { diff --git a/src/HttpHeaderRange.h b/src/HttpHeaderRange.h index 8a184fa1d3..1022bcdb4b 100644 --- a/src/HttpHeaderRange.h +++ b/src/HttpHeaderRange.h @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderRange.h,v 1.5 2003/08/04 22:14:40 robertc Exp $ + * $Id: HttpHeaderRange.h,v 1.6 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -44,8 +44,7 @@ class HttpHdrRangeSpec { public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(HttpHdrRangeSpec); typedef Range HttpRange; static ssize_t const UnknownPosition; @@ -59,11 +58,10 @@ public: bool mergeWith(const HttpHdrRangeSpec * donor); ssize_t offset; ssize_t length; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(HttpHdrRangeSpec) + /* There may be more than one byte range specified in the request. * This object holds all range specs in order of their appearence * in the request because we SHOULD preserve that order. @@ -73,8 +71,7 @@ class HttpHdrRange { public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(HttpHdrRange); static size_t ParsedCount; /* Http Range Header Field */ @@ -107,12 +104,13 @@ public: Vector specs; private: - static MemPool *Pool; void getCanonizedSpecs (Vector ©); void merge (Vector &basis); ssize_t clen; }; +MEMPROXY_CLASS_INLINE(HttpHdrRange) + /* data for iterating thru range specs */ class HttpHdrRangeIter diff --git a/src/HttpReply.cc b/src/HttpReply.cc index 515253c086..7b0468574c 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.65 2003/12/22 10:45:32 robertc Exp $ + * $Id: HttpReply.cc,v 1.66 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -591,22 +591,3 @@ httpReplyBodySize(method_t method, HttpReply const * reply) return reply->content_length; } - -MemPool (*HttpReply::Pool)(NULL); -void * -HttpReply::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (HttpReply)); - - if (!Pool) - Pool = memPoolCreate("HttpReply", sizeof (HttpReply)); - - return memPoolAlloc(Pool); -} - -void -HttpReply::operator delete (void *address) -{ - memPoolFree (Pool, address); -} diff --git a/src/HttpReply.h b/src/HttpReply.h index d69bafeacd..22b1e7a742 100644 --- a/src/HttpReply.h +++ b/src/HttpReply.h @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.h,v 1.6 2003/09/01 03:49:37 robertc Exp $ + * $Id: HttpReply.h,v 1.7 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -85,8 +85,7 @@ class HttpReply { public: - void *operator new (size_t); - void operator delete (void *); + MEMPROXY_CLASS(HttpReply); HttpReply(); /* unsupported, writable, may disappear/change in the future */ int hdr_sz; /* sums _stored_ status-line, headers, and */ @@ -109,10 +108,8 @@ public: HttpStatusLine sline; HttpHeader header; HttpBody body; /* for small constant memory-resident text bodies only */ - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(HttpReply) #endif /* SQUID_HTTPREPLY_H */ diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 0011c1ab1e..651c29bf9f 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.cc,v 1.46 2004/08/30 03:28:56 robertc Exp $ + * $Id: HttpRequest.cc,v 1.47 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -40,25 +40,6 @@ #include "HttpHeaderRange.h" static void httpRequestHdrCacheInit(HttpRequest * req); -MemPool (*HttpRequest::Pool)(NULL); - -void * -HttpRequest::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (HttpRequest)); - - if (!Pool) - Pool = memPoolCreate("HttpRequest", sizeof (HttpRequest)); - - return memPoolAlloc(Pool); -} - -void -HttpRequest::operator delete (void *address) -{ - memPoolFree (Pool, address); -} HttpRequest::HttpRequest() : header(hoRequest) { diff --git a/src/HttpRequest.h b/src/HttpRequest.h index 1e42c7d33b..bd8ed8f580 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.h,v 1.9 2003/10/16 21:40:17 robertc Exp $ + * $Id: HttpRequest.h,v 1.10 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -58,8 +58,7 @@ class HttpRequest { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(HttpRequest); HttpRequest(); virtual ~HttpRequest() {} @@ -101,9 +100,8 @@ public: String extacl_user; /* User name returned by extacl lookup */ String extacl_passwd; /* Password returned by extacl lookup */ String extacl_log; /* String to be used for access.log purposes */ - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(HttpRequest) + #endif /* SQUID_HTTPREQUEST_H */ diff --git a/src/MemObject.cc b/src/MemObject.cc index 77aed17c5f..626e66b469 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -1,6 +1,6 @@ /* - * $Id: MemObject.cc,v 1.12 2003/08/10 05:11:22 robertc Exp $ + * $Id: MemObject.cc,v 1.13 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -62,35 +62,12 @@ url_checksum(const char *url) #endif -MemPool *MemObject::pool = NULL; - -void * -MemObject::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (MemObject)); - - if (!pool) - pool = memPoolCreate("MemObject", sizeof (MemObject)); - - return memPoolAlloc(pool); -} - -void -MemObject::operator delete (void *address) -{ - memPoolFree(pool, address); -} - size_t MemObject::inUseCount() { - if (!pool) - return 0; - MemPoolStats stats; - memPoolGetStats (&stats, pool); + Pool().getStats (&stats); return stats.items_inuse; } diff --git a/src/MemObject.h b/src/MemObject.h index 5149d2842e..54acae461f 100644 --- a/src/MemObject.h +++ b/src/MemObject.h @@ -1,6 +1,6 @@ /* - * $Id: MemObject.h,v 1.8 2003/08/10 11:00:40 robertc Exp $ + * $Id: MemObject.h,v 1.9 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -50,10 +50,9 @@ class MemObject public: static size_t inUseCount(); + MEMPROXY_CLASS(MemObject); void dump() const; - void *operator new (size_t); - void operator delete (void *); MemObject(char const *, char const *); ~MemObject(); @@ -141,12 +140,12 @@ public: void kickReads(); private: - static MemPool *pool; - /* Read only - this reply must be preserved by store clients */ /* The original reply. possibly with updated metadata. */ HttpReply const *_reply; DeferredReadManager deferredReads; }; +MEMPROXY_CLASS_INLINE(MemObject) + #endif /* SQUID_MEMOBJECT_H */ diff --git a/src/Store.h b/src/Store.h index bc58c59428..49fa79f726 100644 --- a/src/Store.h +++ b/src/Store.h @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.12 2003/08/10 11:00:40 robertc Exp $ + * $Id: Store.h,v 1.13 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -122,7 +122,7 @@ public: #endif private: - static MemPool *pool; + static MemImplementingAllocator *pool; bool validLength() const; }; diff --git a/src/StoreClient.h b/src/StoreClient.h index f31513a69d..2d54c95d41 100644 --- a/src/StoreClient.h +++ b/src/StoreClient.h @@ -1,6 +1,6 @@ /* - * $Id: StoreClient.h,v 1.11 2003/10/20 11:23:38 robertc Exp $ + * $Id: StoreClient.h,v 1.12 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -60,7 +60,7 @@ class store_client public: void *operator new (size_t); - void operator delete(void *); + void operator delete (void *); store_client(StoreEntry *); ~store_client(); bool memReaderHasLowerOffset(off_t) const; @@ -106,8 +106,7 @@ unsigned int copy_event_pending: StoreIOBuffer copyInto; private: - static MemPool *pool; - + CBDATA_CLASS(store_client); void fileRead(); void scheduleDiskRead(); void scheduleMemRead(); diff --git a/src/StoreMetaMD5.cc b/src/StoreMetaMD5.cc index f16ceff45e..cda2548114 100644 --- a/src/StoreMetaMD5.cc +++ b/src/StoreMetaMD5.cc @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaMD5.cc,v 1.3 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreMetaMD5.cc,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 20 Storage Manager Swapfile Metadata * AUTHOR: Kostas Anagnostakis @@ -38,26 +38,6 @@ #include "Store.h" #include "MemObject.h" -MemPool *StoreMetaMD5::pool = NULL; - -void * -StoreMetaMD5::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (StoreMetaMD5)); - - if (!pool) - pool = memPoolCreate("StoreMetaMD5", sizeof (StoreMetaMD5)); - - return memPoolAlloc(pool); -} - -void -StoreMetaMD5::operator delete (void *address) -{ - memPoolFree(pool, address); -} - bool StoreMetaMD5::validLength(int len) const { diff --git a/src/StoreMetaMD5.h b/src/StoreMetaMD5.h index 56a1f5e695..f93433f526 100644 --- a/src/StoreMetaMD5.h +++ b/src/StoreMetaMD5.h @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaMD5.h,v 1.3 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreMetaMD5.h,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -40,8 +40,7 @@ class StoreMetaMD5 : public StoreMeta { public: - void *operator new (size_t); - void operator delete (void *); + MEMPROXY_CLASS(StoreMetaMD5); char getType() const {return STORE_META_KEY_MD5;} @@ -49,8 +48,9 @@ public: bool checkConsistency(StoreEntry *) const; private: - static MemPool *pool; static int md5_mismatches; }; +MEMPROXY_CLASS_INLINE(StoreMetaMD5) + #endif /* SQUID_STOREMETAMD5_H */ diff --git a/src/StoreMetaSTD.cc b/src/StoreMetaSTD.cc index 83363db6ad..010c0963f9 100644 --- a/src/StoreMetaSTD.cc +++ b/src/StoreMetaSTD.cc @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaSTD.cc,v 1.3 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreMetaSTD.cc,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 20 Storage Manager Swapfile Metadata * AUTHOR: Kostas Anagnostakis @@ -38,26 +38,6 @@ #include "Store.h" #include "MemObject.h" -MemPool *StoreMetaSTD::pool = NULL; - -void * -StoreMetaSTD::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (StoreMetaSTD)); - - if (!pool) - pool = memPoolCreate("StoreMetaSTD", sizeof (StoreMetaSTD)); - - return memPoolAlloc(pool); -} - -void -StoreMetaSTD::operator delete (void *address) -{ - memPoolFree(pool, address); -} - bool StoreMetaSTD::validLength(int len) const { diff --git a/src/StoreMetaSTD.h b/src/StoreMetaSTD.h index a67c5ea6e6..df241daa0d 100644 --- a/src/StoreMetaSTD.h +++ b/src/StoreMetaSTD.h @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaSTD.h,v 1.3 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreMetaSTD.h,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -40,16 +40,14 @@ class StoreMetaSTD : public StoreMeta { public: - void *operator new (size_t); - void operator delete (void *); + MEMPROXY_CLASS(StoreMetaSTD); char getType() const {return STORE_META_STD;} bool validLength(int) const; // bool checkConsistency(StoreEntry *) const; - -private: - static MemPool *pool; }; +MEMPROXY_CLASS_INLINE(StoreMetaSTD) + #endif /* SQUID_STOREMETASTD_H */ diff --git a/src/StoreMetaURL.cc b/src/StoreMetaURL.cc index 4cc7ee7eb1..36f7421e46 100644 --- a/src/StoreMetaURL.cc +++ b/src/StoreMetaURL.cc @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaURL.cc,v 1.3 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreMetaURL.cc,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 20 Storage Manager Swapfile Metadata * AUTHOR: Kostas Anagnostakis @@ -38,26 +38,6 @@ #include "Store.h" #include "MemObject.h" -MemPool *StoreMetaURL::pool = NULL; - -void * -StoreMetaURL::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (StoreMetaURL)); - - if (!pool) - pool = memPoolCreate("StoreMetaURL", sizeof (StoreMetaURL)); - - return memPoolAlloc(pool); -} - -void -StoreMetaURL::operator delete (void *address) -{ - memPoolFree(pool, address); -} - bool StoreMetaURL::checkConsistency(StoreEntry *e) const { diff --git a/src/StoreMetaURL.h b/src/StoreMetaURL.h index bb476e6b60..70a586b40e 100644 --- a/src/StoreMetaURL.h +++ b/src/StoreMetaURL.h @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaURL.h,v 1.3 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreMetaURL.h,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -40,15 +40,13 @@ class StoreMetaURL : public StoreMeta { public: - void *operator new (size_t); - void operator delete (void *); + MEMPROXY_CLASS(StoreMetaURL); char getType() const {return STORE_META_URL;} bool checkConsistency(StoreEntry *) const; - -private: - static MemPool *pool; }; +MEMPROXY_CLASS_INLINE(StoreMetaURL) + #endif /* SQUID_STOREMETAURL_H */ diff --git a/src/StoreMetaVary.cc b/src/StoreMetaVary.cc index 2a7a1cb07c..9cf20edd4c 100644 --- a/src/StoreMetaVary.cc +++ b/src/StoreMetaVary.cc @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaVary.cc,v 1.3 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreMetaVary.cc,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 20 Storage Manager Swapfile Metadata * AUTHOR: Kostas Anagnostakis @@ -38,26 +38,6 @@ #include "Store.h" #include "MemObject.h" -MemPool *StoreMetaVary::pool = NULL; - -void * -StoreMetaVary::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (StoreMetaVary)); - - if (!pool) - pool = memPoolCreate("StoreMetaVary", sizeof (StoreMetaVary)); - - return memPoolAlloc(pool); -} - -void -StoreMetaVary::operator delete (void *address) -{ - memPoolFree(pool, address); -} - bool StoreMetaVary::checkConsistency(StoreEntry *e) const { diff --git a/src/StoreMetaVary.h b/src/StoreMetaVary.h index 0b1d80576b..9372e494c2 100644 --- a/src/StoreMetaVary.h +++ b/src/StoreMetaVary.h @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaVary.h,v 1.3 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreMetaVary.h,v 1.4 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -40,15 +40,13 @@ class StoreMetaVary : public StoreMeta { public: - void *operator new (size_t); - void operator delete (void *); + MEMPROXY_CLASS(StoreMetaVary); char getType() const {return STORE_META_VARY_HEADERS;} bool checkConsistency(StoreEntry *) const; - -private: - static MemPool *pool; }; +MEMPROXY_CLASS_INLINE(StoreMetaVary) + #endif /* SQUID_STOREMETAVARY_H */ diff --git a/src/StoreSwapLogData.cc b/src/StoreSwapLogData.cc index f8bfc55491..18f7917bbf 100644 --- a/src/StoreSwapLogData.cc +++ b/src/StoreSwapLogData.cc @@ -1,5 +1,5 @@ /* - * $Id: StoreSwapLogData.cc,v 1.2 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreSwapLogData.cc,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -38,23 +38,3 @@ StoreSwapLogData::StoreSwapLogData(): op(0), swap_filen (0), timestamp (0), last { memset (key, '\0', sizeof(key)); } - -MemPool (*StoreSwapLogData::Pool)(NULL); - -void * -StoreSwapLogData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (StoreSwapLogData)); - - if (!Pool) - Pool = memPoolCreate("StoreSwapLogData", sizeof (StoreSwapLogData)); - - return memPoolAlloc(Pool); -} - -void -StoreSwapLogData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} diff --git a/src/StoreSwapLogData.h b/src/StoreSwapLogData.h index 3681fa442b..507eb39018 100644 --- a/src/StoreSwapLogData.h +++ b/src/StoreSwapLogData.h @@ -1,6 +1,6 @@ /* - * $Id: StoreSwapLogData.h,v 1.2 2003/08/04 22:14:41 robertc Exp $ + * $Id: StoreSwapLogData.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -49,8 +49,7 @@ class StoreSwapLogData { public: - void *operator new (size_t byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(StoreSwapLogData); StoreSwapLogData(); char op; sfileno swap_filen; @@ -62,9 +61,8 @@ public: u_short refcount; u_short flags; unsigned char key[MD5_DIGEST_CHARS]; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(StoreSwapLogData) + #endif /* SQUID_STORESWAPLOGDATA_H */ diff --git a/src/acl.cc b/src/acl.cc index 2cb8d4b974..d97d46b0e0 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,5 +1,5 @@ /* - * $Id: acl.cc,v 1.313 2003/10/20 12:33:01 robertc Exp $ + * $Id: acl.cc,v 1.314 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -597,25 +597,6 @@ acl_access::containsPURGE() const /* to be split into separate files in the future */ -MemPool (*ACLList::Pool)(NULL); -void * -ACLList::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLList)); - - if (!Pool) - Pool = memPoolCreate("ACLList", sizeof (ACLList)); - - return memPoolAlloc(Pool); -} - -void -ACLList::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - CBDATA_CLASS_INIT(acl_access); void * diff --git a/src/asn.cc b/src/asn.cc index 9ba0887940..93c389d7ed 100644 --- a/src/asn.cc +++ b/src/asn.cc @@ -1,6 +1,6 @@ /* - * $Id: asn.cc,v 1.98 2003/10/20 12:33:01 robertc Exp $ + * $Id: asn.cc,v 1.99 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -559,25 +559,6 @@ printRadixNode(struct squid_radix_node *rn, void *_sentry) return 0; } -MemPool (*ACLASN::Pool)(NULL); -void * -ACLASN::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLASN)); - - if (!Pool) - Pool = memPoolCreate("ACLASN", sizeof (ACLASN)); - - return memPoolAlloc(Pool); -} - -void -ACLASN::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - ACLASN::~ACLASN() { if (data) diff --git a/src/auth/basic/auth_basic.cc b/src/auth/basic/auth_basic.cc index 379a28aa89..4dcbbda676 100644 --- a/src/auth/basic/auth_basic.cc +++ b/src/auth/basic/auth_basic.cc @@ -1,5 +1,5 @@ /* - * $Id: auth_basic.cc,v 1.30 2004/08/30 03:29:00 robertc Exp $ + * $Id: auth_basic.cc,v 1.31 2004/08/30 05:12:32 robertc Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -118,25 +118,6 @@ AuthBasicConfig::type() const return basicScheme::GetInstance().type(); } -MemPool (*AuthBasicUserRequest::Pool)(NULL); -void * -AuthBasicUserRequest::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (AuthBasicUserRequest)); - - if (!Pool) - Pool = memPoolCreate("AuthBasicUserRequest", sizeof (AuthBasicUserRequest)); - - return memPoolAlloc(Pool); -} - -void -AuthBasicUserRequest::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - AuthBasicUserRequest::AuthBasicUserRequest() : _theUser(NULL) {} @@ -380,31 +361,12 @@ authBasicAuthUserFindUsername(const char *username) return NULL; } -MemPool *BasicUser::Pool (NULL); void BasicUser::deleteSelf() const { delete this; } -void * -BasicUser::operator new(size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (BasicUser)); - - if (!Pool) - Pool = memPoolCreate("Authenticate Basic User Data", sizeof (BasicUser)); - - return memPoolAlloc(Pool); -} - -void -BasicUser::operator delete (void *address) -{ - memPoolFree(Pool, address); -} - BasicUser::BasicUser(AuthConfig *config) : AuthUser (config) , passwd (NULL), credentials_checkedtime(0), auth_queue(NULL), cleartext (NULL), currentRequest (NULL), httpAuthHeader (NULL) { flags.credentials_ok = 0; diff --git a/src/auth/basic/auth_basic.h b/src/auth/basic/auth_basic.h index 05b8462f64..b143818824 100644 --- a/src/auth/basic/auth_basic.h +++ b/src/auth/basic/auth_basic.h @@ -41,9 +41,9 @@ class BasicUser : public AuthUser { public: + MEMPROXY_CLASS(BasicUser); + virtual void deleteSelf() const; - void *operator new(size_t); - void operator delete (void *); BasicUser(AuthConfig *); ~BasicUser(); bool authenticated() const; @@ -70,7 +70,6 @@ unsigned int credentials_ok: BasicAuthQueueNode *auth_queue; private: - static MemPool *Pool; void decodeCleartext(); void extractUsername(); void extractPassword(); @@ -79,6 +78,8 @@ private: char const *httpAuthHeader; }; +MEMPROXY_CLASS_INLINE(BasicUser) + typedef class BasicUser basic_data; /* follows the http request around */ @@ -87,8 +88,8 @@ class AuthBasicUserRequest : public AuthUserRequest { public: - void *operator new (size_t); - void operator delete (void *); + MEMPROXY_CLASS(AuthBasicUserRequest); + AuthBasicUserRequest(); virtual ~AuthBasicUserRequest(); @@ -103,10 +104,11 @@ public: virtual void user (AuthUser *aUser) {_theUser=dynamic_cast(aUser);} private: - static MemPool *Pool; BasicUser *_theUser; }; +MEMPROXY_CLASS_INLINE(AuthBasicUserRequest) + /* configuration runtime data */ class AuthBasicConfig : public AuthConfig diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index 925251827b..c3e3a40802 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_digest.cc,v 1.33 2004/08/30 03:29:00 robertc Exp $ + * $Id: auth_digest.cc,v 1.34 2004/08/30 05:12:32 robertc Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -60,7 +60,7 @@ static hash_table *digest_nonce_cache; static AuthDigestConfig digestConfig; static int authdigest_initialised = 0; -static MemPool *digest_nonce_pool = NULL; +static MemAllocatorProxy *digest_nonce_pool = NULL; CBDATA_TYPE(DigestAuthenticateStateData); @@ -105,7 +105,7 @@ authDigestNonceEncode(digest_nonce_h * nonce) static digest_nonce_h * authenticateDigestNonceNew(void) { - digest_nonce_h *newnonce = static_cast < digest_nonce_h * >(memPoolAlloc(digest_nonce_pool)); + digest_nonce_h *newnonce = static_cast < digest_nonce_h * >(digest_nonce_pool->alloc()); digest_nonce_h *temp; /* NONCE CREATION - NOTES AND REASONING. RBC 20010108 @@ -190,7 +190,7 @@ authenticateDigestNonceDelete(digest_nonce_h * nonce) safe_free(nonce->key); - memPoolFree(digest_nonce_pool, nonce); + digest_nonce_pool->free(nonce); } } @@ -198,7 +198,7 @@ static void authenticateDigestNonceSetup(void) { if (!digest_nonce_pool) - digest_nonce_pool = memPoolCreate("Digest Scheme nonce's", sizeof(digest_nonce_h)); + digest_nonce_pool = new MemAllocatorProxy("Digest Scheme nonce's", sizeof(digest_nonce_h)); if (!digest_nonce_cache) { digest_nonce_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string); @@ -227,7 +227,8 @@ authenticateDigestNonceShutdown(void) #if DEBUGSHUTDOWN if (digest_nonce_pool) { - memPoolDestroy(&digest_nonce_pool); + delete digest_nonce_pool; + digest_nonce_pool = NULL; } #endif @@ -1355,26 +1356,6 @@ AuthDigestUserRequest::module_start(RH * handler, void *data) helperSubmit(digestauthenticators, buf, authenticateDigestHandleReply, r); } - -MemPool (*DigestUser::Pool)(NULL); -void * -DigestUser::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (DigestUser)); - - if (!Pool) - Pool = memPoolCreate("Authentication Digest User data", sizeof (DigestUser)); - - return memPoolAlloc(Pool); -} - -void -DigestUser::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - DigestUser::DigestUser (AuthConfig *config) : AuthUser (config), HA1created (0) {} @@ -1408,25 +1389,6 @@ AuthDigestUserRequest::credentials(CredentialsState newCreds) credentials_ok = newCreds; } -MemPool (*AuthDigestUserRequest::Pool)(NULL); -void * -AuthDigestUserRequest::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (AuthDigestUserRequest)); - - if (!Pool) - Pool = memPoolCreate("AuthDigestUserRequest", sizeof (AuthDigestUserRequest)); - - return memPoolAlloc(Pool); -} - -void -AuthDigestUserRequest::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - AuthDigestUserRequest::AuthDigestUserRequest() : nonceb64(NULL) ,cnonce(NULL) ,realm(NULL), pszPass(NULL) ,algorithm(NULL) ,pszMethod(NULL), qop(NULL) ,uri(NULL) ,response(NULL), diff --git a/src/auth/digest/auth_digest.h b/src/auth/digest/auth_digest.h index 0f18747a4a..9d299fc3f8 100644 --- a/src/auth/digest/auth_digest.h +++ b/src/auth/digest/auth_digest.h @@ -29,8 +29,7 @@ class DigestUser : public AuthUser { public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(DigestUser); DigestUser(AuthConfig *); ~DigestUser(); @@ -41,10 +40,10 @@ public: /* what nonces have been allocated to this user */ dlink_list nonces; -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(DigestUser) + typedef class DigestUser digest_user_h; /* the digest_request structure is what follows the http_request around */ @@ -54,8 +53,7 @@ class AuthDigestUserRequest : public AuthUserRequest public: enum CredentialsState {Unchecked, Ok, Pending, Failed}; - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(AuthDigestUserRequest); AuthDigestUserRequest(); virtual ~AuthDigestUserRequest(); @@ -110,11 +108,12 @@ unsigned int helper_queried: digest_nonce_h *nonce; private: - static MemPool *Pool; DigestUser *_theUser; CredentialsState credentials_ok; }; +MEMPROXY_CLASS_INLINE(AuthDigestUserRequest) + /* data to be encoded into the nonce's b64 representation */ struct _digest_nonce_data diff --git a/src/auth/ntlm/auth_ntlm.cc b/src/auth/ntlm/auth_ntlm.cc index 03922790d0..82a077b453 100644 --- a/src/auth/ntlm/auth_ntlm.cc +++ b/src/auth/ntlm/auth_ntlm.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_ntlm.cc,v 1.40 2004/08/30 03:29:00 robertc Exp $ + * $Id: auth_ntlm.cc,v 1.41 2004/08/30 05:12:32 robertc Exp $ * * DEBUG: section 29 NTLM Authenticator * AUTHOR: Robert Collins @@ -69,8 +69,8 @@ CBDATA_TYPE(authenticateStateData); static int authntlm_initialised = 0; -static MemPool *ntlm_helper_state_pool = NULL; -static MemPool *ntlm_user_hash_pool = NULL; +static MemAllocatorProxy *ntlm_helper_state_pool = NULL; +static MemAllocatorProxy *ntlm_user_hash_pool = NULL; static auth_ntlm_config ntlmConfig; @@ -105,9 +105,16 @@ ntlmScheme::done() #if DEBUGSHUTDOWN if (ntlm_helper_state_pool) { - memPoolDestroy(&ntlm_helper_state_pool); + delete ntlm_helper_state_pool; + ntlm_helper_state_pool = NULL; } + /* Removed for some reason.. + if (ntlm_user_pool) { + delete ntlm_user_pool;ntlm_user_pool = NULL; + } + */ + #endif debug(29, 2) ("authNTLMDone: NTLM authentication Shutdown.\n"); } @@ -193,11 +200,11 @@ AuthNTLMConfig::init(AuthConfig * scheme) if (authenticate) { if (!ntlm_helper_state_pool) - ntlm_helper_state_pool = memPoolCreate("NTLM Helper State data", sizeof(ntlm_helper_state_t)); + ntlm_helper_state_pool = new MemAllocatorProxy("NTLM Helper State data", sizeof(ntlm_helper_state_t)); if (!ntlm_user_hash_pool) - ntlm_user_hash_pool = memPoolCreate("NTLM Header Hash Data", sizeof(struct ProxyAuthCachePointer)); + ntlm_user_hash_pool = new MemAllocatorProxy("NTLM Header Hash Data", sizeof(struct ProxyAuthCachePointer)); authntlm_initialised = 1; @@ -372,7 +379,7 @@ NTLMUser::~NTLMUser() hash_remove_link(proxy_auth_cache, (hash_link *) proxy_auth_hash); /* free the key (usually the proxy_auth header) */ xfree(proxy_auth_hash->key); - memPoolFree(ntlm_user_hash_pool, proxy_auth_hash); + ntlm_user_hash_pool->free(proxy_auth_hash); } } @@ -932,7 +939,7 @@ authenticateProxyAuthCacheAddLink(const char *key, auth_user_t * auth_user) node = node->next; } - proxy_auth_hash = static_cast(memPoolAlloc(ntlm_user_hash_pool)); + proxy_auth_hash = static_cast(ntlm_user_hash_pool->alloc()); proxy_auth_hash->key = xstrdup(key); proxy_auth_hash->auth_user = auth_user; dlinkAddTail(proxy_auth_hash, &proxy_auth_hash->link, &ntlm_user->proxy_auth_list); @@ -1124,25 +1131,6 @@ AuthNTLMUserRequest::authenticate(HttpRequest * request, ConnStateData::Pointer return; } -MemPool (*AuthNTLMUserRequest::Pool)(NULL); -void * -AuthNTLMUserRequest::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (AuthNTLMUserRequest)); - - if (!Pool) - Pool = memPoolCreate("AuthNTLMUserRequest", sizeof (AuthNTLMUserRequest)); - - return memPoolAlloc(Pool); -} - -void -AuthNTLMUserRequest::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - AuthNTLMUserRequest::AuthNTLMUserRequest() : ntlmnegotiate(NULL), authchallenge(NULL), ntlmauthenticate(NULL), authserver(NULL), auth_state(AUTHENTICATE_STATE_NONE), authserver_deferred(0), conn(NULL), _theUser(NULL) @@ -1166,31 +1154,12 @@ AuthNTLMUserRequest::~AuthNTLMUserRequest() } } -MemPool *NTLMUser::Pool (NULL); void NTLMUser::deleteSelf() const { delete this; } -void * -NTLMUser::operator new(size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (NTLMUser)); - - if (!Pool) - Pool = memPoolCreate("Authenticate NTLM User Data", sizeof (NTLMUser)); - - return memPoolAlloc(Pool); -} - -void -NTLMUser::operator delete (void *address) -{ - memPoolFree(Pool, address); -} - NTLMUser::NTLMUser (AuthConfig *config) : AuthUser (config) { proxy_auth_list.head = proxy_auth_list.tail = NULL; diff --git a/src/auth/ntlm/auth_ntlm.h b/src/auth/ntlm/auth_ntlm.h index c48b28e925..434c0c9d44 100644 --- a/src/auth/ntlm/auth_ntlm.h +++ b/src/auth/ntlm/auth_ntlm.h @@ -36,25 +36,22 @@ class NTLMUser : public AuthUser { public: + MEMPROXY_CLASS(NTLMUser); virtual void deleteSelf() const; - void *operator new(size_t); - void operator delete (void *); NTLMUser(AuthConfig *); ~NTLMUser(); dlink_list proxy_auth_list; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(NTLMUser) + typedef class NTLMUser ntlm_user_t; class AuthNTLMUserRequest : public AuthUserRequest { public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(AuthNTLMUserRequest); AuthNTLMUserRequest(); virtual ~AuthNTLMUserRequest(); @@ -86,11 +83,12 @@ public: ConnStateData::Pointer conn; private: - static MemPool *Pool; /* the user */ NTLMUser * _theUser; }; +MEMPROXY_CLASS_INLINE(AuthNTLMUserRequest) + struct _ntlm_helper_state_t { char *challenge; /* the challenge to use with this helper */ diff --git a/src/authenticate.cc b/src/authenticate.cc index 7899b1a08c..5cbd8ef420 100644 --- a/src/authenticate.cc +++ b/src/authenticate.cc @@ -1,6 +1,6 @@ /* - * $Id: authenticate.cc,v 1.65 2004/08/30 03:28:57 robertc Exp $ + * $Id: authenticate.cc,v 1.66 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -47,14 +47,6 @@ #include "HttpReply.h" #include "HttpRequest.h" -/* - * - * Private Data - * - */ - -MemPool *AuthUserHashPointer::pool = NULL; - /**** PUBLIC FUNCTIONS (ALL GENERIC!) ****/ int @@ -164,23 +156,6 @@ AuthUserHashPointer::removeFromCache(void *usernamehash_p) */ } -void * -AuthUserHashPointer::operator new (size_t byteCount) -{ - assert (byteCount == sizeof (AuthUserHashPointer)); - - if (!pool) - pool = memPoolCreate("Auth user hash link", sizeof(AuthUserHashPointer)); - - return static_cast(memPoolAlloc(pool)); -} - -void -AuthUserHashPointer::operator delete (void *address) -{ - memPoolFree(pool, address); -} - AuthUserHashPointer::AuthUserHashPointer (auth_user_t * anAuth_user): auth_user (anAuth_user) { diff --git a/src/authenticate.h b/src/authenticate.h index 30866adeb0..7c51e09818 100644 --- a/src/authenticate.h +++ b/src/authenticate.h @@ -1,6 +1,6 @@ /* - * $Id: authenticate.h,v 1.14 2004/08/30 03:28:58 robertc Exp $ + * $Id: authenticate.h,v 1.15 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -44,19 +44,18 @@ struct AuthUserHashPointer : public hash_link public: static void removeFromCache (void *anAuthUserHashPointer); + MEMPROXY_CLASS(AuthUserHashPointer); AuthUserHashPointer (AuthUser *); - void *operator new (size_t byteCount); - void operator delete (void *address); AuthUser *user() const; private: - static MemPool *pool; - AuthUser *auth_user; }; +MEMPROXY_CLASS_INLINE(AuthUserHashPointer) + class ConnStateData; class AuthScheme; diff --git a/src/cbdata.cc b/src/cbdata.cc index bc164fdc04..644d56bc84 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -1,6 +1,6 @@ /* - * $Id: cbdata.cc,v 1.63 2004/08/30 03:28:58 robertc Exp $ + * $Id: cbdata.cc,v 1.64 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 45 Callback Data Registry * ORIGINAL AUTHOR: Duane Wessels @@ -158,7 +158,7 @@ static OBJH cbdataDumpHistory; struct CBDataIndex { - MemPool *pool; + MemAllocatorProxy *pool; FREE *free_func; } @@ -202,7 +202,7 @@ cbdataInternalInitType(cbdata_type type, const char *name, int size, FREE * free assert((size_t)cbdata::Offset == (sizeof(cbdata) - ((cbdata *)NULL)->dataSize())); - cbdata_index[type].pool = memPoolCreate(label, size + cbdata::Offset); + cbdata_index[type].pool = new MemAllocatorProxy(label, size + cbdata::Offset); cbdata_index[type].free_func = free_func; } @@ -260,8 +260,8 @@ cbdataInternalAlloc(cbdata_type type) { cbdata *p; assert(type > 0 && type < cbdata_types); - p = new (memPoolAlloc(cbdata_index[type].pool)) cbdata; - // p = (cbdata *)memPoolAlloc(cbdata_index[type].pool); + p = new (cbdata_index[type].pool->alloc()) cbdata; + // p = (cbdata *)cbdata_index[type].pool->alloc(); p->type = type; p->valid = 1; @@ -332,7 +332,7 @@ cbdataInternalFree(void *p) * we could use the normal delete operator * and it would Just Work. RBC 20030902 */ - memPoolFree(cbdata_index[theType].pool, c); + cbdata_index[theType].pool->free(c); return NULL; } @@ -430,7 +430,7 @@ cbdataInternalUnlock(const void *p) * we could use the normal delete operator * and it would Just Work. RBC 20030902 */ - memPoolFree(cbdata_index[theType].pool, c); + cbdata_index[theType].pool->free(c); } int @@ -514,11 +514,11 @@ cbdataDump(StoreEntry * sentry) storeAppendPrintf(sentry, "types\tsize\tallocated\ttotal\n"); for (int i = 1; i < cbdata_types; i++) { - MemPool *pool = cbdata_index[i].pool; + MemAllocatorProxy *pool = cbdata_index[i].pool; if (pool) { - int obj_size = pool->obj_size - cbdata::Offset; - storeAppendPrintf(sentry, "%s\t%d\t%d\t%d\n", pool->label + 7, obj_size, pool->meter.inuse.level, obj_size * pool->meter.inuse.level); + int obj_size = pool->objectSize() - cbdata::Offset; + storeAppendPrintf(sentry, "%s\t%d\t%d\t%d\n", pool->objectType() + 7, obj_size, pool->getMeter().inuse.level, obj_size * pool->getMeter().inuse.level); } } diff --git a/src/comm.cc b/src/comm.cc index fe6e5aa176..7e9e5b41eb 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.394 2004/04/03 14:07:38 hno Exp $ + * $Id: comm.cc,v 1.395 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -214,8 +214,7 @@ class CommCallbackData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(CommCallbackData); CommCallbackData(CommCommonCallback const &); virtual ~CommCallbackData() {} @@ -235,73 +234,74 @@ protected: friend void comm_calliocallback(void); private: - static MemPool *Pool; dlink_node fd_node; dlink_node h_node; }; +MEMPROXY_CLASS_INLINE(CommCallbackData) + class CommReadCallbackData : public CommCallbackData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(CommReadCallbackData); CommReadCallbackData(CommCommonCallback const &, CallBack aCallback, int); virtual comm_callback_t getType() const { return COMM_CB_READ; } virtual void callCallback(); private: - static MemPool *Pool; CallBack callback; int retval; }; +MEMPROXY_CLASS_INLINE(CommReadCallbackData); + class CommAcceptCallbackData : public CommCallbackData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(CommAcceptCallbackData); CommAcceptCallbackData(int const anFd, CallBack, comm_err_t, int, int, ConnectionDetail const &); virtual void callCallback(); private: - static MemPool *Pool; CallBack callback; int newfd; ConnectionDetail details; }; +MEMPROXY_CLASS_INLINE(CommAcceptCallbackData) + class CommFillCallbackData : public CommCallbackData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(CommFillCallbackData); CommFillCallbackData(int const anFd, CallBack aCallback, comm_err_t, int); virtual void callCallback(); private: - static MemPool *Pool; CallBack callback; }; +MEMPROXY_CLASS_INLINE(CommFillCallbackData) + class CommWriteCallbackData : public CommCallbackData { public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(CommWriteCallbackData); CommWriteCallbackData(int const anFd, CallBack aCallback, comm_err_t, int, int); virtual void callCallback(); private: - static MemPool *Pool; CallBack callback; int retval; }; +MEMPROXY_CLASS_INLINE(CommWriteCallbackData) + struct _fd_debug_t { char const *close_file; @@ -310,8 +310,8 @@ struct _fd_debug_t typedef struct _fd_debug_t fd_debug_t; -static MemPool *comm_write_pool = NULL; -static MemPool *conn_close_pool = NULL; +static MemAllocator *comm_write_pool = NULL; +static MemAllocator *conn_close_pool = NULL; fdc_t *fdc_table = NULL; fd_debug_t *fdd_table = NULL; dlink_list CommCallbackList; @@ -319,101 +319,6 @@ dlink_list CommCallbackList; /* New and improved stuff */ -MemPool (*CommCallbackData::Pool)(NULL); -void * -CommCallbackData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (CommCallbackData)); - - if (!Pool) - Pool = memPoolCreate("CommCallbackData", sizeof (CommCallbackData)); - - return memPoolAlloc(Pool); -} - -void -CommCallbackData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - -MemPool (*CommReadCallbackData::Pool)(NULL); -void * -CommReadCallbackData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (CommReadCallbackData)); - - if (!Pool) - Pool = memPoolCreate("CommReadCallbackData", sizeof (CommReadCallbackData)); - - return memPoolAlloc(Pool); -} - -void -CommReadCallbackData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - -MemPool (*CommAcceptCallbackData::Pool)(NULL); -void * -CommAcceptCallbackData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (CommAcceptCallbackData)); - - if (!Pool) - Pool = memPoolCreate("CommAcceptCallbackData", sizeof (CommAcceptCallbackData)); - - return memPoolAlloc(Pool); -} - -void -CommAcceptCallbackData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - -MemPool (*CommFillCallbackData::Pool)(NULL); -void * -CommFillCallbackData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (CommFillCallbackData)); - - if (!Pool) - Pool = memPoolCreate("CommFillCallbackData", sizeof (CommFillCallbackData)); - - return memPoolAlloc(Pool); -} - -void -CommFillCallbackData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - -MemPool (*CommWriteCallbackData::Pool)(NULL); -void * -CommWriteCallbackData::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (CommWriteCallbackData)); - - if (!Pool) - Pool = memPoolCreate("CommWriteCallbackData", sizeof (CommWriteCallbackData)); - - return memPoolAlloc(Pool); -} - -void -CommWriteCallbackData::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - CommCallbackData::CommCallbackData(CommCommonCallback const &newResults) : result (newResults) { assert(fdc_table[result.fd].active == 1); @@ -1073,7 +978,7 @@ CommWriteStateCallbackAndFree(int fd, comm_err_t code) if (callback && cbdataReferenceValidDone(CommWriteState->handler_data, &cbdata)) callback(fd, CommWriteState->buf, CommWriteState->offset, code, cbdata); - memPoolFree(comm_write_pool, CommWriteState); + comm_write_pool->free(CommWriteState); } /* Return the local port associated with fd. */ @@ -1691,7 +1596,7 @@ commCallCloseHandlers(int fd) while (F->closeHandler != NULL) { close_handler ch = *F->closeHandler; - memPoolFree(conn_close_pool, F->closeHandler); /* AAA */ + conn_close_pool->free(F->closeHandler); /* AAA */ F->closeHandler = ch.next; ch.next = NULL; debug(5, 5) ("commCallCloseHandlers: ch->handler=%p data=%p\n", ch.handler, ch.data); @@ -1952,7 +1857,7 @@ comm_udp_sendto(int fd, void comm_add_close_handler(int fd, PF * handler, void *data) { - close_handler *newHandler = (close_handler *)memPoolAlloc(conn_close_pool); /* AAA */ + close_handler *newHandler = (close_handler *)conn_close_pool->alloc(); /* AAA */ close_handler *c; debug(5, 5) ("comm_add_close_handler: FD %d, handler=%p, data=%p\n", fd, handler, data); @@ -1993,7 +1898,7 @@ comm_remove_close_handler(int fd, PF * handler, void *data) cbdataReferenceDone(p->data); - memPoolFree(conn_close_pool, p); + conn_close_pool->free(p); } static void @@ -2142,9 +2047,9 @@ comm_init(void) { * Since Squid_MaxFD can be as high as several thousand, don't waste them */ RESERVED_FD = XMIN(100, Squid_MaxFD / 4); - comm_write_pool = memPoolCreate("CommWriteStateData", sizeof(CommWriteStateData)); + comm_write_pool = MemPools::GetInstance().create("CommWriteStateData", sizeof(CommWriteStateData)); - conn_close_pool = memPoolCreate("close_handler", sizeof(close_handler)); + conn_close_pool = MemPools::GetInstance().create("close_handler", sizeof(close_handler)); } /* Write to FD. */ @@ -2231,11 +2136,11 @@ comm_old_write(int fd, const char *buf, int size, CWCB * handler, void *handler_ * triggered yet */ fatalf ("comm_write: fd_table[%d].wstate != NULL\n", fd); - memPoolFree(comm_write_pool, state); + comm_write_pool->free(state); fd_table[fd].wstate = NULL; } - fd_table[fd].wstate = state = (CommWriteStateData *)memPoolAlloc(comm_write_pool); + fd_table[fd].wstate = state = (CommWriteStateData *)comm_write_pool->alloc(); state->buf = (char *) buf; state->size = size; state->offset = 0; diff --git a/src/external_acl.cc b/src/external_acl.cc index a7e0a211d6..c62511315f 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -1,6 +1,6 @@ /* - * $Id: external_acl.cc,v 1.57 2004/08/30 03:28:59 robertc Exp $ + * $Id: external_acl.cc,v 1.58 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -1264,25 +1264,6 @@ ACLExternal::ACLExternal (ACLExternal const & old) : data (NULL), class_ (old.cl assert (!old.data); } -MemPool (*ACLExternal::Pool)(NULL); -void * -ACLExternal::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLExternal)); - - if (!Pool) - Pool = memPoolCreate("ACLExternal", sizeof (ACLExternal)); - - return memPoolAlloc(Pool); -} - -void -ACLExternal::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - char const * ACLExternal::typeString() const { diff --git a/src/fs/aufs/aiops.cc b/src/fs/aufs/aiops.cc index b3f99bac47..618d540ecb 100644 --- a/src/fs/aufs/aiops.cc +++ b/src/fs/aufs/aiops.cc @@ -1,5 +1,5 @@ /* - * $Id: aiops.cc,v 1.24 2003/06/19 16:42:40 hno Exp $ + * $Id: aiops.cc,v 1.25 2004/08/30 05:12:32 robertc Exp $ * * DEBUG: section 43 AIOPS * AUTHOR: Stewart Forster @@ -140,15 +140,15 @@ static int squidaio_initialised = 0; #define AIO_TINY_BUFS AIO_LARGE_BUFS >> 3 #define AIO_MICRO_BUFS 128 -static MemPool *squidaio_large_bufs = NULL; /* 16K */ -static MemPool *squidaio_medium_bufs = NULL; /* 8K */ -static MemPool *squidaio_small_bufs = NULL; /* 4K */ -static MemPool *squidaio_tiny_bufs = NULL; /* 2K */ -static MemPool *squidaio_micro_bufs = NULL; /* 128K */ +static MemAllocatorProxy *squidaio_large_bufs = NULL; /* 16K */ +static MemAllocatorProxy *squidaio_medium_bufs = NULL; /* 8K */ +static MemAllocatorProxy *squidaio_small_bufs = NULL; /* 4K */ +static MemAllocatorProxy *squidaio_tiny_bufs = NULL; /* 2K */ +static MemAllocatorProxy *squidaio_micro_bufs = NULL; /* 128K */ static int request_queue_len = 0; -static MemPool *squidaio_request_pool = NULL; -static MemPool *squidaio_thread_pool = NULL; +static MemAllocatorProxy *squidaio_request_pool = NULL; +static MemAllocatorProxy *squidaio_thread_pool = NULL; static squidaio_request_queue_t request_queue; static struct @@ -178,10 +178,10 @@ static struct sched_param globsched; #endif static pthread_t main_thread; -static MemPool * +static MemAllocatorProxy * squidaio_get_pool(int size) { - MemPool *p; + MemAllocatorProxy *p; if (size <= AIO_LARGE_BUFS) { if (size <= AIO_MICRO_BUFS) @@ -204,10 +204,10 @@ void * squidaio_xmalloc(int size) { void *p; - MemPool *pool; + MemAllocatorProxy *pool; if ((pool = squidaio_get_pool(size)) != NULL) { - p = memPoolAlloc(pool); + p = pool->alloc(); } else p = xmalloc(size); @@ -229,10 +229,10 @@ squidaio_xstrdup(const char *str) void squidaio_xfree(void *p, int size) { - MemPool *pool; + MemAllocatorProxy *pool; if ((pool = squidaio_get_pool(size)) != NULL) { - memPoolFree(pool, p); + pool->free(p); } else xfree(p); } @@ -240,11 +240,11 @@ squidaio_xfree(void *p, int size) static void squidaio_xstrfree(char *str) { - MemPool *pool; + MemAllocatorProxy *pool; int len = strlen(str) + 1; if ((pool = squidaio_get_pool(len)) != NULL) { - memPoolFree(pool, str); + pool->free(str); } else xfree(str); } @@ -320,12 +320,12 @@ squidaio_init(void) done_queue.blocked = 0; /* Create threads and get them to sit in their wait loop */ - squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t)); + squidaio_thread_pool = new MemAllocatorProxy("aio_thread", sizeof(squidaio_thread_t)); assert(NUMTHREADS); for (i = 0; i < NUMTHREADS; i++) { - threadp = (squidaio_thread_t *)memPoolAlloc(squidaio_thread_pool); + threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc(); threadp->status = _THREAD_STARTING; threadp->current_req = NULL; threadp->requests = 0; @@ -340,17 +340,17 @@ squidaio_init(void) } /* Create request pool */ - squidaio_request_pool = memPoolCreate("aio_request", sizeof(squidaio_request_t)); + squidaio_request_pool = new MemAllocatorProxy("aio_request", sizeof(squidaio_request_t)); - squidaio_large_bufs = memPoolCreate("squidaio_large_bufs", AIO_LARGE_BUFS); + squidaio_large_bufs = new MemAllocatorProxy("squidaio_large_bufs", AIO_LARGE_BUFS); - squidaio_medium_bufs = memPoolCreate("squidaio_medium_bufs", AIO_MEDIUM_BUFS); + squidaio_medium_bufs = new MemAllocatorProxy("squidaio_medium_bufs", AIO_MEDIUM_BUFS); - squidaio_small_bufs = memPoolCreate("squidaio_small_bufs", AIO_SMALL_BUFS); + squidaio_small_bufs = new MemAllocatorProxy("squidaio_small_bufs", AIO_SMALL_BUFS); - squidaio_tiny_bufs = memPoolCreate("squidaio_tiny_bufs", AIO_TINY_BUFS); + squidaio_tiny_bufs = new MemAllocatorProxy("squidaio_tiny_bufs", AIO_TINY_BUFS); - squidaio_micro_bufs = memPoolCreate("squidaio_micro_bufs", AIO_MICRO_BUFS); + squidaio_micro_bufs = new MemAllocatorProxy("squidaio_micro_bufs", AIO_MICRO_BUFS); squidaio_initialised = 1; } @@ -636,7 +636,7 @@ squidaio_cleanup_request(squidaio_request_t * requestp) resultp->aio_errno = requestp->err; } - memPoolFree(squidaio_request_pool, requestp); + squidaio_request_pool->free(requestp); } /* squidaio_cleanup_request */ @@ -667,7 +667,7 @@ squidaio_open(const char *path, int oflag, mode_t mode, squidaio_result_t * resu if (!squidaio_initialised) squidaio_init(); - requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool); + requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); requestp->path = (char *) squidaio_xstrdup(path); @@ -705,7 +705,7 @@ squidaio_read(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_r if (!squidaio_initialised) squidaio_init(); - requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool); + requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); requestp->fd = fd; @@ -748,7 +748,7 @@ squidaio_write(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_ if (!squidaio_initialised) squidaio_init(); - requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool); + requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); requestp->fd = fd; @@ -792,7 +792,7 @@ squidaio_close(int fd, squidaio_result_t * resultp) if (!squidaio_initialised) squidaio_init(); - requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool); + requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); requestp->fd = fd; @@ -827,7 +827,7 @@ squidaio_stat(const char *path, struct stat *sb, squidaio_result_t * resultp) if (!squidaio_initialised) squidaio_init(); - requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool); + requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); requestp->path = (char *) squidaio_xstrdup(path); @@ -865,7 +865,7 @@ squidaio_unlink(const char *path, squidaio_result_t * resultp) if (!squidaio_initialised) squidaio_init(); - requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool); + requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); requestp->path = squidaio_xstrdup(path); @@ -898,7 +898,7 @@ squidaio_truncate(const char *path, off_t length, squidaio_result_t * resultp) if (!squidaio_initialised) squidaio_init(); - requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool); + requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); requestp->path = (char *) squidaio_xstrdup(path); @@ -938,7 +938,7 @@ squidaio_opendir(const char *path, squidaio_result_t * resultp) if (!squidaio_initialised) squidaio_init(); - requestp = memPoolAlloc(squidaio_request_pool); + requestp = squidaio_request_pool->alloc(); resultp->result_type = _AIO_OP_OPENDIR; diff --git a/src/fs/aufs/async_io.cc b/src/fs/aufs/async_io.cc index c949b27470..bdc62789b3 100644 --- a/src/fs/aufs/async_io.cc +++ b/src/fs/aufs/async_io.cc @@ -1,6 +1,6 @@ /* - * $Id: async_io.cc,v 1.24 2003/07/22 15:23:10 robertc Exp $ + * $Id: async_io.cc,v 1.25 2004/08/30 05:12:32 robertc Exp $ * * DEBUG: section 32 Asynchronous Disk I/O * AUTHOR: Pete Bentley @@ -96,7 +96,7 @@ squidaio_unlinkq_t; static dlink_list used_list; static OBJH aioStats; -static MemPool *squidaio_ctrl_pool; +static MemAllocatorProxy *squidaio_ctrl_pool; static void aioFDWasClosed(int fd); static void @@ -112,7 +112,7 @@ AufsIO::init(void) if (initialised) return; - squidaio_ctrl_pool = memPoolCreate("aio_ctrl", sizeof(squidaio_ctrl_t)); + squidaio_ctrl_pool = new MemAllocatorProxy("aio_ctrl", sizeof(squidaio_ctrl_t)); cachemgrRegister("squidaio_counts", "Async IO Function Counters", aioStats, 0, 1); @@ -126,7 +126,9 @@ AufsIO::done(void) if (!initialised) return; - memPoolDestroy(&squidaio_ctrl_pool); + delete squidaio_ctrl_pool; + + squidaio_ctrl_pool = NULL; initialised = false; } @@ -138,7 +140,7 @@ aioOpen(const char *path, int oflag, mode_t mode, AIOCB * callback, void *callba assert(AufsIO::Instance.initialised); squidaio_counts.open_start++; - ctrlp = (squidaio_ctrl_t *)memPoolAlloc(squidaio_ctrl_pool); + ctrlp = (squidaio_ctrl_t *)squidaio_ctrl_pool->alloc(); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = cbdataReference(callback_data); @@ -157,7 +159,7 @@ aioClose(int fd) assert(AufsIO::Instance.initialised); squidaio_counts.close_start++; aioCancel(fd); - ctrlp = (squidaio_ctrl_t *)memPoolAlloc(squidaio_ctrl_pool); + ctrlp = (squidaio_ctrl_t *)squidaio_ctrl_pool->alloc(); ctrlp->fd = fd; ctrlp->done_handler = NULL; ctrlp->done_handler_data = NULL; @@ -205,7 +207,7 @@ aioCancel(int fd) } dlinkDelete(m, &used_list); - memPoolFree(squidaio_ctrl_pool, ctrlp); + squidaio_ctrl_pool->free(ctrlp); } } @@ -218,7 +220,7 @@ aioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callba assert(AufsIO::Instance.initialised); squidaio_counts.write_start++; - ctrlp = (squidaio_ctrl_t *)memPoolAlloc(squidaio_ctrl_pool); + ctrlp = (squidaio_ctrl_t *)squidaio_ctrl_pool->alloc(); ctrlp->fd = fd; ctrlp->done_handler = callback; ctrlp->done_handler_data = cbdataReference(callback_data); @@ -247,7 +249,7 @@ aioRead(int fd, int offset, int len, AIOCB * callback, void *callback_data) assert(AufsIO::Instance.initialised); squidaio_counts.read_start++; - ctrlp = (squidaio_ctrl_t *)memPoolAlloc(squidaio_ctrl_pool); + ctrlp = (squidaio_ctrl_t *)squidaio_ctrl_pool->alloc(); ctrlp->fd = fd; ctrlp->done_handler = callback; ctrlp->done_handler_data = cbdataReference(callback_data); @@ -276,7 +278,7 @@ aioStat(char *path, struct stat *sb, AIOCB * callback, void *callback_data) assert(AufsIO::Instance.initialised); squidaio_counts.stat_start++; - ctrlp = (squidaio_ctrl_t *)memPoolAlloc(squidaio_ctrl_pool); + ctrlp = (squidaio_ctrl_t *)squidaio_ctrl_pool->alloc(); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = cbdataReference(callback_data); @@ -293,7 +295,7 @@ aioUnlink(const char *path, AIOCB * callback, void *callback_data) squidaio_ctrl_t *ctrlp; assert(AufsIO::Instance.initialised); squidaio_counts.unlink_start++; - ctrlp = (squidaio_ctrl_t *)memPoolAlloc(squidaio_ctrl_pool); + ctrlp = (squidaio_ctrl_t *)squidaio_ctrl_pool->alloc(); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = cbdataReference(callback_data); @@ -309,7 +311,7 @@ aioTruncate(const char *path, off_t length, AIOCB * callback, void *callback_dat squidaio_ctrl_t *ctrlp; assert(AufsIO::Instance.initialised); squidaio_counts.unlink_start++; - ctrlp = (squidaio_ctrl_t *)memPoolAlloc(squidaio_ctrl_pool); + ctrlp = (squidaio_ctrl_t *)squidaio_ctrl_pool->alloc(); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = cbdataReference(callback_data); @@ -406,7 +408,7 @@ AufsIO::callback() if (ctrlp->operation == _AIO_CLOSE) aioFDWasClosed(ctrlp->fd); - memPoolFree(squidaio_ctrl_pool, ctrlp); + squidaio_ctrl_pool->free(ctrlp); } return retval; @@ -450,5 +452,5 @@ AufsIO::AufsIO() : initialised (false) {} int aioQueueSize(void) { - return memPoolInUseCount(squidaio_ctrl_pool); + return squidaio_ctrl_pool->inUseCount(); } diff --git a/src/fs/coss/StoreFScoss.cc b/src/fs/coss/StoreFScoss.cc index 743a8af439..c24a67c0b5 100644 --- a/src/fs/coss/StoreFScoss.cc +++ b/src/fs/coss/StoreFScoss.cc @@ -1,6 +1,6 @@ /* - * $Id: StoreFScoss.cc,v 1.2 2003/08/27 21:19:38 wessels Exp $ + * $Id: StoreFScoss.cc,v 1.3 2004/08/30 05:12:32 robertc Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Robert Collins @@ -65,7 +65,7 @@ StoreFScoss::type() const void StoreFScoss::done() { - /* memPoolDestroy(&coss_index_pool); XXX Should be here? */ + /* delete coss_index_pool;coss_index_pool = NULL; XXX Should be here? */ cachemgrRegister("coss", "COSS Stats", storeCossStats, 0, 1); initialised = false; } @@ -83,7 +83,7 @@ StoreFScoss::setup() { assert(!initialised); - coss_index_pool = memPoolCreate("COSS index data", sizeof(CossIndexNode)); + coss_index_pool = new MemAllocatorProxy("COSS index data", sizeof(CossIndexNode)); initialised = true; } diff --git a/src/fs/coss/store_coss.h b/src/fs/coss/store_coss.h index 4d2e5a375d..ea887421c9 100644 --- a/src/fs/coss/store_coss.h +++ b/src/fs/coss/store_coss.h @@ -83,8 +83,7 @@ class CossState : public storeIOState { public: - void * operator new (size_t); - void operator delete (void *); + MEMPROXY_CLASS(CossState); CossState(CossSwapDir *); ~CossState(); @@ -113,19 +112,18 @@ unsigned int writing: void close(); CossSwapDir *SD; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(CossState) + typedef struct _cossmembuf CossMemBuf; typedef struct _cossindex CossIndexNode; /* Whether the coss system has been setup or not */ extern int coss_initialised; -extern MemPool *coss_membuf_pool; -extern MemPool *coss_index_pool; +extern MemAllocatorProxy *coss_membuf_pool; +extern MemAllocatorProxy *coss_index_pool; class CossSwapDir : public SwapDir { diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index 9d1f590ffa..803f453ae1 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.52 2004/03/03 09:34:58 adrian Exp $ + * $Id: store_dir_coss.cc,v 1.53 2004/08/30 05:12:32 robertc Exp $ * * DEBUG: section 47 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -45,7 +45,7 @@ int n_coss_dirs = 0; /* static int last_coss_pick_index = -1; */ -MemPool *coss_index_pool = NULL; +MemAllocatorProxy *coss_index_pool = NULL; typedef struct _RebuildState RebuildState; @@ -181,14 +181,14 @@ storeCossRemove(CossSwapDir * sd, StoreEntry * e) CossIndexNode *coss_node = (CossIndexNode *)e->repl.data; e->repl.data = NULL; dlinkDelete(&coss_node->node, &sd->cossindex); - memPoolFree(coss_index_pool, coss_node); + coss_index_pool->free(coss_node); sd->count -= 1; } void storeCossAdd(CossSwapDir * sd, StoreEntry * e) { - CossIndexNode *coss_node = (CossIndexNode *)memPoolAlloc(coss_index_pool); + CossIndexNode *coss_node = (CossIndexNode *)coss_index_pool->alloc(); assert(!e->repl.data); e->repl.data = coss_node; dlinkAdd(e, &coss_node->node, &sd->cossindex); diff --git a/src/fs/coss/store_io_coss.cc b/src/fs/coss/store_io_coss.cc index b86a6471ca..d7e9e5bb72 100644 --- a/src/fs/coss/store_io_coss.cc +++ b/src/fs/coss/store_io_coss.cc @@ -1,6 +1,6 @@ /* - * $Id: store_io_coss.cc,v 1.24 2003/08/30 06:39:24 robertc Exp $ + * $Id: store_io_coss.cc,v 1.25 2004/08/30 05:12:33 robertc Exp $ * * DEBUG: section 79 Storage Manager COSS Interface * AUTHOR: Eric Stern @@ -59,23 +59,6 @@ CBDATA_TYPE(CossMemBuf); /* === PUBLIC =========================================================== */ -MemPool *CossState::Pool = NULL; - -void * -CossState::operator new (size_t) -{ - if (!Pool) - Pool = memPoolCreate("Squid COSS State Data", sizeof (CossState)); - - return memPoolAlloc(Pool); -} - -void -CossState::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - CossState::CossState(CossSwapDir *aCSD):SD (aCSD) {} diff --git a/src/fs/ufs/store_io_ufs.cc b/src/fs/ufs/store_io_ufs.cc index ec4311e4a4..fefb273bd9 100644 --- a/src/fs/ufs/store_io_ufs.cc +++ b/src/fs/ufs/store_io_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.23 2003/08/31 12:44:31 robertc Exp $ + * $Id: store_io_ufs.cc,v 1.24 2004/08/30 05:12:33 robertc Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -538,23 +538,6 @@ UFSStoreState::kickReadQueue() return true; } -MemPool * UFSStoreState::_queued_read::Pool = NULL; - -void * -UFSStoreState::_queued_read::operator new(size_t size) -{ - if (!Pool) - Pool = memPoolCreate("AUFS Queued read data",sizeof (_queued_read)); - - return memPoolAlloc (Pool); -} - -void -UFSStoreState::_queued_read::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - void UFSStoreState::queueRead(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) { @@ -570,23 +553,6 @@ UFSStoreState::queueRead(char *buf, size_t size, off_t offset, STRCB *callback, linklistPush(&pending_reads, q); } -MemPool * UFSStoreState::_queued_write::Pool = NULL; - -void * -UFSStoreState::_queued_write::operator new(size_t size) -{ - if (!Pool) - Pool = memPoolCreate("AUFS Queued write data",sizeof (_queued_write)); - - return memPoolAlloc (Pool); -} - -void -UFSStoreState::_queued_write::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - bool UFSStoreState::kickWriteQueue() { diff --git a/src/helper.cc b/src/helper.cc index 599c34bbc1..0f60377571 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -1,6 +1,6 @@ /* - * $Id: helper.cc,v 1.60 2003/08/04 22:14:42 robertc Exp $ + * $Id: helper.cc,v 1.61 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Harvest Derived? @@ -232,7 +232,7 @@ helperStatefulOpenServers(statefulhelper * hlp) srv->parent = cbdataReference(hlp); if (hlp->datapool != NULL) - srv->data = memPoolAlloc(hlp->datapool); + srv->data = hlp->datapool->alloc(); dlinkAddTail(srv, &srv->link, &hlp->servers); @@ -846,7 +846,7 @@ helperStatefulServerFree(int fd, void *data) } if (srv->data != NULL) - memPoolFree(hlp->datapool, srv->data); + hlp->datapool->free(srv->data); cbdataReferenceDone(srv->parent); @@ -1455,26 +1455,6 @@ helperRequestFree(helper_request * r) delete r; } -MemPool (*helper_request::Pool)(NULL); - -void * -helper_request::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (helper_request)); - - if (!Pool) - Pool = memPoolCreate("helper_request", sizeof (helper_request)); - - return memPoolAlloc(Pool); -} - -void -helper_request::operator delete (void *address) -{ - memPoolFree (Pool, address); -} - static void helperStatefulRequestFree(helper_stateful_request * r) { @@ -1482,23 +1462,3 @@ helperStatefulRequestFree(helper_stateful_request * r) xfree(r->buf); delete r; } - -MemPool (*helper_stateful_request::Pool)(NULL); - -void * -helper_stateful_request::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (helper_stateful_request)); - - if (!Pool) - Pool = memPoolCreate("helper_stateful_request", sizeof (helper_stateful_request)); - - return memPoolAlloc(Pool); -} - -void -helper_stateful_request::operator delete (void *address) -{ - memPoolFree (Pool, address); -} diff --git a/src/helper.h b/src/helper.h index 639ca1f220..8c28682f05 100644 --- a/src/helper.h +++ b/src/helper.h @@ -1,6 +1,6 @@ /* - * $Id: helper.h,v 1.2 2003/08/04 22:14:42 robertc Exp $ + * $Id: helper.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Harvest Derived? @@ -42,31 +42,27 @@ class helper_request { public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(helper_request); char *buf; HLPCB *callback; void *data; struct timeval dispatch_time; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(helper_request) + class helper_stateful_request { public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(helper_stateful_request); char *buf; HLPSCB *callback; int placeholder; /* if 1, this is a dummy request waiting for a stateful helper to become available for deferred requests.*/ void *data; - -private: - static MemPool *Pool; }; +MEMPROXY_CLASS_INLINE(helper_stateful_request) + #endif /* SQUID_HELPER_H */ diff --git a/src/htcp.cc b/src/htcp.cc index 99bc6be0df..870d7d5e6b 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -1,6 +1,6 @@ /* - * $Id: htcp.cc,v 1.56 2003/08/10 11:00:43 robertc Exp $ + * $Id: htcp.cc,v 1.57 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -126,8 +126,7 @@ class htcpSpecifier : public StoreClient { public: - void *operator new (unsigned int byteCount); - void operator delete (void *address); + MEMPROXY_CLASS(htcpSpecifier); void created (StoreEntry *newEntry); void checkHit(); @@ -141,13 +140,14 @@ public: char *req_hdrs; private: - static MemPool *pool; HttpRequest *checkHitRequest; struct sockaddr_in *from; htcpDataHeader *dhdr; }; +MEMPROXY_CLASS_INLINE(htcpSpecifier) + struct _htcpDetail { char *resp_hdrs; @@ -210,8 +210,7 @@ static int htcpInSocket = -1; static int htcpOutSocket = -1; #define N_QUERIED_KEYS 256 static cache_key queried_keys[N_QUERIED_KEYS][MD5_DIGEST_CHARS]; -MemPool *htcpSpecifier::pool = NULL; -static MemPool *htcpDetailPool = NULL; +static MemAllocator *htcpDetailPool = NULL; static char *htcpBuildPacket(htcpStuff * stuff, ssize_t * len); @@ -553,24 +552,6 @@ htcpSend(const char *buf, int len, struct sockaddr_in *to) * STUFF FOR RECEIVING HTCP MESSAGES */ -void * -htcpSpecifier::operator new (unsigned int byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (htcpSpecifier)); - - if (!pool) - pool = memPoolCreate("htcpSpecifier", sizeof(htcpSpecifier)); - - return static_cast (memPoolAlloc(pool)); -} - -void -htcpSpecifier::operator delete (void *address) -{ - memPoolFree(pool, address); -} - void htcpSpecifier::setFrom (struct sockaddr_in *aSocket) @@ -600,7 +581,7 @@ htcpFreeDetail(htcpDetail * d) safe_free(d->resp_hdrs); safe_free(d->entity_hdrs); safe_free(d->cache_hdrs); - memPoolFree(htcpDetailPool, d); + htcpDetailPool->free(d); } static int @@ -688,7 +669,7 @@ htcpUnpackSpecifier(char *buf, int sz) static htcpDetail * htcpUnpackDetail(char *buf, int sz) { - htcpDetail *d = static_cast(memPoolAlloc(htcpDetailPool)); + htcpDetail *d = static_cast(htcpDetailPool->alloc()); int o; debug(31, 3) ("htcpUnpackDetail: %d bytes\n", (int) sz); o = htcpUnpackCountstr(buf, sz, &d->resp_hdrs); @@ -1196,7 +1177,7 @@ htcpInit(void) } if (!htcpDetailPool) { - htcpDetailPool = memPoolCreate("htcpDetail", sizeof(htcpDetail)); + htcpDetailPool = MemPools::GetInstance().create("htcpDetail", sizeof(htcpDetail)); } } diff --git a/src/main.cc b/src/main.cc index 930c6b1ea2..2893f58571 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.392 2004/08/30 03:28:59 robertc Exp $ + * $Id: main.cc,v 1.393 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -104,9 +104,9 @@ usage(void) { fprintf(stderr, #if USE_WIN32_SERVICE - "Usage: %s [-dhirsvzCDFNRVYX] [-f config-file] [-[au] port] [-k signal] [-n name] [-O CommandLine]\n" + "Usage: %s [-cdhirsvzCDFNRVYX] [-f config-file] [-[au] port] [-k signal] [-n name] [-O CommandLine]\n" #else - "Usage: %s [-dhsvzCDFNRVYX] [-f config-file] [-[au] port] [-k signal]\n" + "Usage: %s [-cdhsvzCDFNRVYX] [-f config-file] [-[au] port] [-k signal]\n" #endif " -a port Specify HTTP port number (default: %d).\n" " -d level Write debugging to stderr also.\n" diff --git a/src/mem.cc b/src/mem.cc index 1ba8ece1f0..aaebd7186e 100644 --- a/src/mem.cc +++ b/src/mem.cc @@ -1,6 +1,6 @@ /* - * $Id: mem.cc,v 1.84 2003/09/29 10:24:01 robertc Exp $ + * $Id: mem.cc,v 1.85 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -44,7 +44,7 @@ static void memStringStats(StoreEntry * sentry); /* module locals */ -static MemPool *MemPools[MEM_MAX]; +static MemImplementingAllocator *MemPools[MEM_MAX]; static double xm_time = 0; static double xm_deltat = 0; @@ -72,7 +72,7 @@ StrPoolsAttrs[mem_str_pool_count] = { static struct { - MemPool *pool; + MemAllocator *pool; } StrPools[mem_str_pool_count]; @@ -98,14 +98,14 @@ memStringStats(StoreEntry * sentry) /* table body */ for (i = 0; i < mem_str_pool_count; i++) { - const MemPool *pool = StrPools[i].pool; - const int plevel = pool->meter.inuse.level; + const MemAllocator *pool = StrPools[i].pool; + const int plevel = pool->getMeter().inuse.level; storeAppendPrintf(sentry, pfmt, - pool->label, + pool->objectType(), xpercentInt(plevel, StrCountMeter.level), - xpercentInt(plevel * pool->obj_size, StrVolumeMeter.level)); + xpercentInt(plevel * pool->objectSize(), StrVolumeMeter.level)); pooled_count += plevel; - pooled_volume += plevel * pool->obj_size; + pooled_volume += plevel * pool->objectSize(); } /* malloc strings */ @@ -139,23 +139,6 @@ Mem::Stats(StoreEntry * sentry) * public routines */ -int -memPoolInUseCount(MemPool * pool) -{ - MemPoolStats stats; - assert(pool); - memPoolGetStats(&stats, pool); - return stats.items_inuse; -} - -int -memPoolsTotalAllocated(void) -{ - MemPoolGlobalStats stats; - memPoolGetGlobalStats(&stats); - return stats.TheMeter->alloc.level; -} - /* * we have a limit on _total_ amount of idle memory so we ignore * max_pages for now @@ -165,7 +148,7 @@ memDataInit(mem_type type, const char *name, size_t size, int max_pages_notused) { assert(name && size); assert(MemPools[type] == NULL); - MemPools[type] = memPoolCreate(name, size); + MemPools[type] = MemPools::GetInstance().create(name, size); } @@ -173,14 +156,14 @@ memDataInit(mem_type type, const char *name, size_t size, int max_pages_notused) void * memAllocate(mem_type type) { - return memPoolAlloc(MemPools[type]); + return MemPools[type]->alloc(); } /* give memory back to the pool */ void memFree(void *p, int type) { - memPoolFree(MemPools[type], p); + MemPools[type]->free(p); } /* allocate a variable size buffer using best-fit pool */ @@ -188,7 +171,7 @@ void * memAllocString(size_t net_size, size_t * gross_size) { int i; - MemPool *pool = NULL; + MemAllocator *pool = NULL; assert(gross_size); for (i = 0; i < mem_str_pool_count; i++) { @@ -202,7 +185,7 @@ memAllocString(size_t net_size, size_t * gross_size) assert(*gross_size >= net_size); memMeterInc(StrCountMeter); memMeterAdd(StrVolumeMeter, *gross_size); - return pool ? memPoolAlloc(pool) : xcalloc(1, net_size); + return pool ? pool->alloc() : xcalloc(1, net_size); } extern size_t memStringCount(); @@ -222,7 +205,7 @@ void memFreeString(size_t size, void *buf) { int i; - MemPool *pool = NULL; + MemAllocator *pool = NULL; assert(size && buf); for (i = 0; i < mem_str_pool_count; i++) { @@ -235,7 +218,7 @@ memFreeString(size_t size, void *buf) memMeterDec(StrCountMeter); memMeterDel(StrVolumeMeter, size); - pool ? memPoolFree(pool, buf) : xfree(buf); + pool ? pool->free(buf) : xfree(buf); } /* Find the best fit MEM_X_BUF type */ @@ -333,16 +316,14 @@ static double clean_interval = 15.0; /* time to live of idle chunk before releas void Mem::CleanIdlePools(void *unused) { - memPoolClean(static_cast(clean_interval)); + MemPools::GetInstance().clean(static_cast(clean_interval)); eventAdd("memPoolCleanIdlePools", CleanIdlePools, NULL, clean_interval, 1); } -static unsigned int mem_idle_limit = 0; - void memConfigure(void) { - unsigned int new_pool_limit; + size_t new_pool_limit; /* set to configured value first */ if (!Config.onoff.mem_pools) @@ -352,12 +333,10 @@ memConfigure(void) else new_pool_limit = mem_unlimited_size; - if (mem_idle_limit > new_pool_limit) + if (MemPools::GetInstance().idleLimit() > new_pool_limit) debug(13, 1) ("Shrinking idle mem pools to %.2f MB\n", toMB(new_pool_limit)); - memPoolSetIdleLimit(new_pool_limit); - - mem_idle_limit = new_pool_limit; + MemPools::GetInstance().setIdleLimit(new_pool_limit); } /* XXX make these classes do their own memory management */ @@ -369,7 +348,7 @@ Mem::Init(void) int i; debug(13, 1) ("Memory pools are '%s'; limit: %.2f MB\n", - (Config.onoff.mem_pools ? "on" : "off"), toMB(mem_idle_limit)); + (Config.onoff.mem_pools ? "on" : "off"), toMB(MemPools::GetInstance().idleLimit())); /* set all pointers to null */ memset(MemPools, '\0', sizeof(MemPools)); @@ -410,17 +389,15 @@ Mem::Init(void) memDataInit(MEM_WORDLIST, "wordlist", sizeof(wordlist), 0); memDataInit(MEM_CLIENT_INFO, "ClientInfo", sizeof(ClientInfo), 0); memDataInit(MEM_MD5_DIGEST, "MD5 digest", MD5_DIGEST_CHARS, 0); - memPoolSetChunkSize(MemPools[MEM_MD5_DIGEST], 512 * 1024); + MemPools[MEM_MD5_DIGEST]->setChunkSize(512 * 1024); /* init string pools */ for (i = 0; i < mem_str_pool_count; i++) { - StrPools[i].pool = memPoolCreate(StrPoolsAttrs[i].name, StrPoolsAttrs[i].obj_size); + StrPools[i].pool = MemPools::GetInstance().create(StrPoolsAttrs[i].name, StrPoolsAttrs[i].obj_size); - if (StrPools[i].pool->obj_size != StrPoolsAttrs[i].obj_size) - debugs(13, 1, "Notice: " << StrPoolsAttrs[i].name << " is " << - StrPools[i].pool->obj_size << " bytes instead of requested " - << StrPoolsAttrs[i].obj_size << " bytes"); + if (StrPools[i].pool->objectSize() != StrPoolsAttrs[i].obj_size) + debug(13, 1) ("Notice: %s is %d bytes instead of requested %d bytes\n", StrPoolsAttrs[i].name, StrPoolsAttrs[i].obj_size, StrPoolsAttrs[i].obj_size); } cachemgrRegister("mem", @@ -457,9 +434,9 @@ memCheckInit(void) #if UNUSED_CODE /* to-do: make debug level a parameter? */ -static void memPoolDescribe(const MemPool * pool); +static void memPoolDescribe(const MemAllocator * pool); static void -memPoolDescribe(const MemPool * pool) +memPoolDescribe(const MemAllocator * pool) { assert(pool); debug(13, 2) ("%-20s: %6d x %4d bytes = %5d KB\n", @@ -473,8 +450,8 @@ void memClean(void) { MemPoolGlobalStats stats; - memPoolSetIdleLimit(0); - memPoolClean(0); + MemPools::GetInstance().setIdleLimit(0); + MemPools::GetInstance().clean(0); memPoolGetGlobalStats(&stats); if (stats.tot_items_inuse) @@ -629,7 +606,7 @@ Mem::Report(StoreEntry * e) static MemPoolGlobalStats mp_total; int not_used = 0; MemPoolIterator *iter; - MemPool *pool; + MemAllocator *pool; /* caption */ storeAppendPrintf(e, "Current memory usage:\n"); @@ -662,12 +639,12 @@ Mem::Report(StoreEntry * e) iter = memPoolIterate(); while ((pool = memPoolIterateNext(iter))) { - memPoolGetStats(&mp_stats, pool); + pool->getStats(&mp_stats); if (!mp_stats.pool) /* pool destroyed */ continue; - if (mp_stats.pool->meter.gb_saved.count > 0) /* this pool has been used */ + if (mp_stats.pool->getMeter().gb_saved.count > 0) /* this pool has been used */ PoolReport(&mp_stats, mp_total.TheMeter, e); else not_used++; diff --git a/src/mem_node.cc b/src/mem_node.cc index c9d61d960d..788309a8c4 100644 --- a/src/mem_node.cc +++ b/src/mem_node.cc @@ -1,6 +1,6 @@ /* - * $Id: mem_node.cc,v 1.5 2003/08/04 22:14:42 robertc Exp $ + * $Id: mem_node.cc,v 1.6 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -36,27 +36,8 @@ #include "squid.h" #include "mem_node.h" -MemPool *mem_node::pool = NULL; unsigned long mem_node::store_mem_size; -void * -mem_node::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (mem_node)); - - if (!pool) - pool = memPoolCreate("mem_node", sizeof (mem_node)); - - return memPoolAlloc(pool); -} - -void -mem_node::operator delete (void *address) -{ - memPoolFree(pool, address); -} - mem_node::mem_node(off_t offset):nodeBuffer(0,offset,data) {} @@ -68,12 +49,9 @@ mem_node::~mem_node() size_t mem_node::InUseCount() { - if (!pool) - return 0; - MemPoolStats stats; - memPoolGetStats (&stats, pool); + Pool().getStats (&stats); return stats.items_inuse; } diff --git a/src/mem_node.h b/src/mem_node.h index 1fe3bd4c0c..da43da6168 100644 --- a/src/mem_node.h +++ b/src/mem_node.h @@ -1,6 +1,6 @@ /* - * $Id: mem_node.h,v 1.6 2003/09/22 08:50:51 robertc Exp $ + * $Id: mem_node.h,v 1.7 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -44,8 +44,7 @@ public: static size_t InUseCount(); static unsigned long store_mem_size; /* 0 */ - void operator delete (void *); - void *operator new (size_t); + MEMPROXY_CLASS(mem_node); mem_node(off_t); ~mem_node(); size_t space() const; @@ -59,11 +58,10 @@ public: StoreIOBuffer nodeBuffer; /* Private */ char data[SM_PAGE_SIZE]; - -private: - static MemPool *pool; }; +MEMPROXY_CLASS_INLINE(mem_node) + inline std::ostream & operator << (std::ostream &os, mem_node &aNode) { diff --git a/src/pconn.cc b/src/pconn.cc index c51fa30d35..33b2335d01 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -1,6 +1,6 @@ /* - * $Id: pconn.cc,v 1.43 2004/04/04 13:44:28 hno Exp $ + * $Id: pconn.cc,v 1.44 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -64,7 +64,7 @@ static void pconnDelete(struct _pconn *p); static void pconnRemoveFD(struct _pconn *p, int fd); static OBJH pconnHistDump; -static MemPool *pconn_fds_pool = NULL; +static MemAllocator *pconn_fds_pool = NULL; CBDATA_TYPE(pconn); @@ -91,7 +91,7 @@ static struct _pconn * p->hash.key = xstrdup(key); p->nfds_alloc = PCONN_FDS_SZ; p->nfds = 0; - p->fds = (int *)memPoolAlloc(pconn_fds_pool); + p->fds = (int *)pconn_fds_pool->alloc(); debug(48, 3) ("pconnNew: adding %s\n", hashKeyStr(&p->hash)); hash_join(table, &p->hash); return p; @@ -105,7 +105,7 @@ pconnDelete(struct _pconn *p) hash_remove_link(table, (hash_link *) p); if (p->nfds_alloc == PCONN_FDS_SZ) - memPoolFree(pconn_fds_pool, p->fds); + pconn_fds_pool->free(p->fds); else xfree(p->fds); @@ -235,7 +235,7 @@ pconnInit(void) server_pconn_hist[i] = 0; } - pconn_fds_pool = memPoolCreate("pconn_fds", PCONN_FDS_SZ * sizeof(int)); + pconn_fds_pool = MemPools::GetInstance().create("pconn_fds", PCONN_FDS_SZ * sizeof(int)); cachemgrRegister("pconn", "Persistent Connection Utilization Histograms", @@ -277,7 +277,7 @@ pconnPush(int fd, const char *host, u_short port, const char *domain) xmemcpy(p->fds, old, p->nfds * sizeof(int)); if (p->nfds == PCONN_FDS_SZ) - memPoolFree(pconn_fds_pool, old); + pconn_fds_pool->free(old); else xfree(old); } diff --git a/src/protos.h b/src/protos.h index 38bd516ab5..cd71c66d5b 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.494 2004/04/03 14:25:59 hno Exp $ + * $Id: protos.h,v 1.495 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -185,7 +185,7 @@ SQUIDCEXTERN void _db_print(const char *,...) PRINTF_FORMAT_ARG1; #else SQUIDCEXTERN void _db_print(); #endif -SQUIDCEXTERN void xassert(const char *, const char *, int); +extern void xassert(const char *, const char *, int); /* packs, then prints an object using debug() */ SQUIDCEXTERN void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm); @@ -686,23 +686,9 @@ SQUIDCEXTERN int memInUse(mem_type); SQUIDCEXTERN void memDataInit(mem_type, const char *, size_t, int); SQUIDCEXTERN void memCheckInit(void); -/* MemPool */ -SQUIDCEXTERN MemPool *memPoolCreate(const char *label, size_t obj_size); -SQUIDCEXTERN void *memPoolAlloc(MemPool * pool); -SQUIDCEXTERN void memPoolFree(MemPool * pool, void *obj); -SQUIDCEXTERN void memPoolDestroy(MemPool ** pool); -SQUIDCEXTERN MemPoolIterator *memPoolGetFirst(void); -SQUIDCEXTERN MemPool *memPoolGetNext(MemPoolIterator ** iter); -SQUIDCEXTERN void memPoolSetChunkSize(MemPool * pool, size_t chunksize); -SQUIDCEXTERN void memPoolSetIdleLimit(size_t new_idle_limit); -SQUIDCEXTERN int memPoolGetStats(MemPoolStats * stats, MemPool * pool); -SQUIDCEXTERN int memPoolGetGlobalStats(MemPoolGlobalStats * stats); -SQUIDCEXTERN void memPoolClean(time_t maxage); /* Mem */ SQUIDCEXTERN void memConfigure(void); -SQUIDCEXTERN int memPoolInUseCount(MemPool * pool); -SQUIDCEXTERN int memPoolsTotalAllocated(void); /* ----------------------------------------------------------------- */ diff --git a/src/repl/lru/store_repl_lru.cc b/src/repl/lru/store_repl_lru.cc index 38b276ff04..8f1ec5e4d3 100644 --- a/src/repl/lru/store_repl_lru.cc +++ b/src/repl/lru/store_repl_lru.cc @@ -1,6 +1,6 @@ /* - * $Id: store_repl_lru.cc,v 1.15 2003/09/06 12:47:39 robertc Exp $ + * $Id: store_repl_lru.cc,v 1.16 2004/08/30 05:12:33 robertc Exp $ * * DEBUG: section ? LRU Removal policy * AUTHOR: Henrik Nordstrom @@ -105,7 +105,7 @@ lru_add(RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node) LruPolicyData *lru = (LruPolicyData *)policy->_data; LruNode *lru_node; assert(!node->data); - node->data = lru_node = (LruNode *)memPoolAlloc(lru_node_pool); + node->data = lru_node = (LruNode *)lru_node_pool->alloc(); dlinkAddTail(entry, &lru_node->node, &lru->list); lru->count += 1; @@ -136,7 +136,7 @@ lru_remove(RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node) dlinkDelete(&lru_node->node, &lru->list); - memPoolFree(lru_node_pool, lru_node); + lru_node_pool->free(lru_node); lru->count -= 1; } @@ -252,7 +252,7 @@ try_again: goto try_again; } - memPoolFree(lru_node_pool, lru_node); + lru_node_pool->free(lru_node); lru->count -= 1; lru->setPolicyNode(entry, NULL); return entry; @@ -332,8 +332,9 @@ createRemovalPolicy_lru(wordlist * args) /* Initialize */ if (!lru_node_pool) { - lru_node_pool = memPoolCreate("LRU policy node", sizeof(LruNode)); - memPoolSetChunkSize(lru_node_pool, 512 * 1024); + /* Must be chunked */ + lru_node_pool = new MemPool("LRU policy node", sizeof(LruNode)); + lru_node_pool->setChunkSize(512 * 1024); } /* Allocate the needed structures */ diff --git a/src/squid.h b/src/squid.h index d00fa10914..eae12a7269 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.236 2003/07/14 10:36:42 robertc Exp $ + * $Id: squid.h,v 1.237 2004/08/30 05:12:31 robertc Exp $ * * AUTHOR: Duane Wessels * @@ -402,9 +402,9 @@ max(A const & lhs, A const & rhs) #ifndef malloc #define malloc + #endif -#ifndef free -#define free + -#endif +template +void free(V x) { fatal("Do not use ::free()"); } + #ifndef calloc #define calloc + #endif diff --git a/src/store.cc b/src/store.cc index 621bde64a8..7df3a5ebee 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.576 2003/09/29 10:24:01 robertc Exp $ + * $Id: store.cc,v 1.577 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -110,7 +110,7 @@ static EVH storeLateRelease; * local variables */ static Stack LateReleaseStack; -MemPool *StoreEntry::pool = NULL; +MemImplementingAllocator *StoreEntry::pool = NULL; void * StoreEntry::operator new (size_t bytecount) @@ -118,17 +118,17 @@ StoreEntry::operator new (size_t bytecount) assert (bytecount == sizeof (StoreEntry)); if (!pool) { - pool = memPoolCreate ("StoreEntry", bytecount); - memPoolSetChunkSize(pool, 2048 * 1024); + pool = MemPools::GetInstance().create ("StoreEntry", bytecount); + pool->setChunkSize(2048 * 1024); } - return memPoolAlloc (pool); + return pool->alloc(); } void StoreEntry::operator delete (void *address) { - memPoolFree(pool, address); + pool->free(address); } size_t @@ -139,7 +139,7 @@ StoreEntry::inUseCount() MemPoolStats stats; - memPoolGetStats (&stats, pool); + pool->getStats (&stats); return stats.items_inuse; } diff --git a/src/store_client.cc b/src/store_client.cc index 7e00dad903..e56fc483ce 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.134 2003/10/20 11:23:38 robertc Exp $ + * $Id: store_client.cc,v 1.135 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 90 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -46,8 +46,6 @@ #endif #include "HttpRequest.h" -CBDATA_TYPE(store_client); - /* * NOTE: 'Header' refers to the swapfile metadata header. * 'OBJHeader' refers to the object header, with cannonical @@ -63,21 +61,21 @@ static EVH storeClientCopyEvent; static int CheckQuickAbort2(StoreEntry * entry); static void CheckQuickAbort(StoreEntry * entry); -MemPool *store_client::pool = NULL; +CBDATA_CLASS_INIT(store_client); void * -store_client::operator new (size_t byteCount) +store_client::operator new (size_t) { - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (store_client)); CBDATA_INIT_TYPE(store_client); - return cbdataAlloc(store_client); + store_client *result = cbdataAlloc(store_client); + return result; } void store_client::operator delete (void *address) { - cbdataFree (address); + store_client *t = static_cast(address); + cbdataFree(t); } bool diff --git a/src/structs.h b/src/structs.h index 0e611db4ed..b7c1d19466 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.488 2004/08/30 03:28:59 robertc Exp $ + * $Id: structs.h,v 1.489 2004/08/30 05:12:31 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -895,16 +895,18 @@ class HttpHeaderEntry { public: - void *operator new (size_t); - void operator delete (void *); + MEMPROXY_CLASS(HttpHeaderEntry); http_hdr_type id; String name; String value; - -private: - static MemPool *Pool; }; +/* bah. remove this when HttpHeaderEntry is moved + * out + */ +extern void xassert(const char *, const char *, int); +MEMPROXY_CLASS_INLINE(HttpHeaderEntry) + /* http surogate control header field */ struct _HttpHdrScTarget @@ -1889,7 +1891,7 @@ struct _helper_stateful int n_to_start; int n_running; int ipc_type; - MemPool *datapool; + MemAllocatorProxy *datapool; HLPSAVAIL *IsAvailable; HLPSONEQ *OnEmptyQueue; time_t last_queue_warn; diff --git a/src/tools.cc b/src/tools.cc index 4e72d737ab..869b9fc699 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.242 2004/08/30 03:28:59 robertc Exp $ + * $Id: tools.cc,v 1.243 2004/08/30 05:12:31 robertc Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -63,7 +63,7 @@ SQUIDCEXTERN int setresuid(uid_t, uid_t, uid_t); SQUIDCEXTERN void (*failure_notify) (const char *); -MemPool *dlink_node_pool = NULL; +MemAllocator *dlink_node_pool = NULL; void releaseServerSockets(void) @@ -965,10 +965,10 @@ dlink_node * dlinkNodeNew() { if (dlink_node_pool == NULL) - dlink_node_pool = memPoolCreate("Dlink list nodes", sizeof(dlink_node)); + dlink_node_pool = MemPools::GetInstance().create("Dlink list nodes", sizeof(dlink_node)); - /* where should we call memPoolDestroy(dlink_node_pool); */ - return (dlink_node *)memPoolAlloc(dlink_node_pool); + /* where should we call delete dlink_node_pool;dlink_node_pool = NULL; */ + return (dlink_node *)dlink_node_pool->alloc(); } /* the node needs to be unlinked FIRST */ @@ -978,7 +978,7 @@ dlinkNodeDelete(dlink_node * m) if (m == NULL) return; - memPoolFree(dlink_node_pool, m); + dlink_node_pool->free(m); } void diff --git a/src/ufscommon.h b/src/ufscommon.h index 4edf10b85b..082ebf98a1 100644 --- a/src/ufscommon.h +++ b/src/ufscommon.h @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.8 2003/08/04 22:14:42 robertc Exp $ + * $Id: ufscommon.h,v 1.9 2004/08/30 05:12:31 robertc Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -293,31 +293,25 @@ protected: { public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(UFSStoreState::_queued_read); char *buf; size_t size; off_t offset; STRCB *callback; void *callback_data; - private: - static MemPool *Pool; }; class _queued_write { public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(UFSStoreState::_queued_write); char const *buf; size_t size; off_t offset; FREE *free_func; - private: - static MemPool *Pool; }; /* These should be in the IO strategy */ @@ -341,6 +335,9 @@ private: void openDone(); }; +MEMPROXY_CLASS_INLINE(UFSStoreState::_queued_read) +MEMPROXY_CLASS_INLINE(UFSStoreState::_queued_write) + class RebuildState : public RefCountable { diff --git a/test-suite/MemPoolTest.cc b/test-suite/MemPoolTest.cc index 8fa67eef37..8aa48ad51e 100644 --- a/test-suite/MemPoolTest.cc +++ b/test-suite/MemPoolTest.cc @@ -1,5 +1,5 @@ /* - * $Id: MemPoolTest.cc,v 1.2 2004/08/30 03:29:03 robertc Exp $ + * $Id: MemPoolTest.cc,v 1.3 2004/08/30 05:12:33 robertc Exp $ * * AUTHOR: Robert Collins * @@ -60,18 +60,18 @@ void MemPoolTest::run() { assert (Pool == NULL); - Pool = memPoolCreate ("Test Pool", sizeof(SomethingToAlloc)); + Pool = new MemPool ("Test Pool", sizeof(SomethingToAlloc)); assert (Pool); - SomethingToAlloc *something = static_cast(memPoolAlloc(Pool)); + SomethingToAlloc *something = static_cast(Pool->alloc()); assert (something); assert (something->aValue == 0); something->aValue = 5; - memPoolFree (Pool, something); - SomethingToAlloc *otherthing = static_cast(memPoolAlloc (Pool)); + Pool->free(something); + SomethingToAlloc *otherthing = static_cast(Pool->alloc()); assert (otherthing == something); assert (otherthing->aValue == 0); - memPoolFree (Pool, otherthing); - memPoolDestroy (&Pool); + Pool->free (otherthing); + delete Pool; } int diff --git a/test-suite/splay.cc b/test-suite/splay.cc index 0ee0613b86..1b9085a151 100644 --- a/test-suite/splay.cc +++ b/test-suite/splay.cc @@ -1,5 +1,5 @@ /* - * $Id: splay.cc,v 1.6 2003/09/22 03:31:02 robertc Exp $ + * $Id: splay.cc,v 1.7 2004/08/30 05:12:33 robertc Exp $ * * based on ftp://ftp.cs.cmu.edu/user/sleator/splaying/top-down-splay.c * http://bobo.link.cs.cmu.edu/cgi-bin/splay/splay-cgi.pl @@ -141,18 +141,18 @@ main(int argc, char *argv[]) for (i = 0; i < 100; i++) { I = (intnode *)xcalloc(sizeof(intnode), 1); I->i = random(); - top = splay_insert(I, top, compareintvoid); + top = top->insert(I, compareintvoid); } SplayCheck::BeginWalk(); - splay_walk(top, SplayCheck::WalkVoid, NULL); + top->walk(SplayCheck::WalkVoid, NULL); SplayCheck::BeginWalk(); top->walk(SplayCheck::WalkVoid, NULL); top->destroy(destintvoid); /* check we don't segfault on NULL splay calls */ top = NULL; - top->splay(NULL, compareintvoid); + top->splay((void *)NULL, compareintvoid); } /* test typesafe splay containers */ @@ -174,7 +174,7 @@ main(int argc, char *argv[]) safeTop->destroy(destint); /* check we don't segfault on NULL splay calls */ safeTop = NULL; - safeTop->splay(NULL, compareint); + safeTop->splay((intnode *)NULL, compareint); } { /* intnode */ diff --git a/test-suite/test_tools.cc b/test-suite/test_tools.cc index 8a3c73d4c8..f3d6fef39a 100644 --- a/test-suite/test_tools.cc +++ b/test-suite/test_tools.cc @@ -1,6 +1,6 @@ /* - * $Id: test_tools.cc,v 1.5 2004/08/30 03:29:03 robertc Exp $ + * $Id: test_tools.cc,v 1.6 2004/08/30 05:12:33 robertc Exp $ * * AUTHOR: Robert Collins * @@ -173,16 +173,16 @@ Debug::finishDebug() std::ostringstream *Debug::CurrentDebug (NULL); -MemPool *dlink_node_pool = NULL; +MemImplementingAllocator *dlink_node_pool = NULL; dlink_node * dlinkNodeNew() { if (dlink_node_pool == NULL) - dlink_node_pool = memPoolCreate("Dlink list nodes", sizeof(dlink_node)); + dlink_node_pool = MemPools::GetInstance().create("Dlink list nodes", sizeof(dlink_node)); /* where should we call memPoolDestroy(dlink_node_pool); */ - return (dlink_node *)memPoolAlloc(dlink_node_pool); + return static_cast(dlink_node_pool->alloc()); } /* the node needs to be unlinked FIRST */ @@ -192,7 +192,7 @@ dlinkNodeDelete(dlink_node * m) if (m == NULL) return; - memPoolFree(dlink_node_pool, m); + dlink_node_pool->free(m); } void