]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Merge in MemPools objectification.
authorrobertc <>
Mon, 30 Aug 2004 11:12:29 +0000 (11:12 +0000)
committerrobertc <>
Mon, 30 Aug 2004 11:12:29 +0000 (11:12 +0000)
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

118 files changed:
configure.in
include/List.h
include/MemPool.h
include/memMeter.h
include/splay.h
lib/Makefile.am
lib/Splay.cc
lib/uudecode.c
src/ACL.h
src/ACLARP.cc
src/ACLARP.h
src/ACLASN.h
src/ACLCertificateData.cc
src/ACLCertificateData.h
src/ACLDestinationDomain.cc
src/ACLDestinationDomain.h
src/ACLDestinationIP.cc
src/ACLDestinationIP.h
src/ACLDomainData.cc
src/ACLDomainData.h
src/ACLExtUser.cc
src/ACLExtUser.h
src/ACLIP.cc
src/ACLIP.h
src/ACLIdent.cc
src/ACLIdent.h
src/ACLMaxConnection.cc
src/ACLMaxConnection.h
src/ACLMaxUserIP.cc
src/ACLMaxUserIP.h
src/ACLMethodData.cc
src/ACLMethodData.h
src/ACLMyIP.cc
src/ACLMyIP.h
src/ACLProtocolData.cc
src/ACLProtocolData.h
src/ACLProxyAuth.cc
src/ACLProxyAuth.h
src/ACLRegexData.cc
src/ACLRegexData.h
src/ACLSourceIP.cc
src/ACLSourceIP.h
src/ACLStrategised.h
src/ACLStringData.cc
src/ACLStringData.h
src/ACLTimeData.cc
src/ACLTimeData.h
src/ACLUserData.cc
src/ACLUserData.h
src/ESI.cc
src/ESIAssign.cc
src/ESIAssign.h
src/ESIInclude.cc
src/ESIInclude.h
src/ESILiteral.h
src/ESISequence.cc
src/ESISequence.h
src/ExternalACL.h
src/HttpHdrRange.cc
src/HttpHeader.cc
src/HttpHeaderRange.h
src/HttpReply.cc
src/HttpReply.h
src/HttpRequest.cc
src/HttpRequest.h
src/MemObject.cc
src/MemObject.h
src/Store.h
src/StoreClient.h
src/StoreMetaMD5.cc
src/StoreMetaMD5.h
src/StoreMetaSTD.cc
src/StoreMetaSTD.h
src/StoreMetaURL.cc
src/StoreMetaURL.h
src/StoreMetaVary.cc
src/StoreMetaVary.h
src/StoreSwapLogData.cc
src/StoreSwapLogData.h
src/acl.cc
src/asn.cc
src/auth/basic/auth_basic.cc
src/auth/basic/auth_basic.h
src/auth/digest/auth_digest.cc
src/auth/digest/auth_digest.h
src/auth/ntlm/auth_ntlm.cc
src/auth/ntlm/auth_ntlm.h
src/authenticate.cc
src/authenticate.h
src/cbdata.cc
src/comm.cc
src/external_acl.cc
src/fs/aufs/aiops.cc
src/fs/aufs/async_io.cc
src/fs/coss/StoreFScoss.cc
src/fs/coss/store_coss.h
src/fs/coss/store_dir_coss.cc
src/fs/coss/store_io_coss.cc
src/fs/ufs/store_io_ufs.cc
src/helper.cc
src/helper.h
src/htcp.cc
src/main.cc
src/mem.cc
src/mem_node.cc
src/mem_node.h
src/pconn.cc
src/protos.h
src/repl/lru/store_repl_lru.cc
src/squid.h
src/store.cc
src/store_client.cc
src/structs.h
src/tools.cc
src/ufscommon.h
test-suite/MemPoolTest.cc
test-suite/splay.cc
test-suite/test_tools.cc

index a7551fed47d0b855eb573814428c74cd5fde5624..5e0c9c1ce731377f1350d31105086a06f1120551 100644 (file)
@@ -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])
index d59e6dfec33d52ec1b73494159bb7b54cfc1d8ce..bfe9eb6a16f002a26a9f9c04236addce09702bbe 100644 (file)
@@ -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<class C>
@@ -86,17 +82,6 @@ template <class C>
 void *
 List<C>::operator new (size_t byteCount)
 {
-#if 0
-    /* derived classes with different sizes must implement their own new */
-    assert (byteCount == sizeof (List<C>));
-
-    if (!Pool)
-        Pool = memPoolCreate("List", sizeof (List<C>));
-
-    return memPoolAlloc(Pool);
-
-#endif
-
     CBDATA_INIT_TYPE(List);
 
     List<C> *result = cbdataAlloc(List);
@@ -108,8 +93,6 @@ template <class C>
 void
 List<C>::operator delete (void *address)
 {
-    // MemPoolFree
-    // List<C> *t = static_cast<List<C> *>(address);
     cbdataFree(address);
 }
 
index abb26f9d4ef5f5e3c07973c84e2f2eba1c719c3a..628c89ba401162792cf664b6b5579382a9f768a3 100644 (file)
@@ -4,18 +4,9 @@
 
 #include "config.h"
 #include "util.h"
-#ifdef __cplusplus
 
-template <class V>
-
-class SplayNode;
-
-typedef SplayNode<void *> splayNode;
-
-#else
-#include "splay.h"
-#endif
 #include "memMeter.h"
+#include "splay.h"
 
 #if HAVE_GNUMALLOC_H
 #include <gnumalloc.h>
@@ -33,10 +24,6 @@ typedef SplayNode<void *> 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<void *> 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<MemChunk *> 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_ */
index b353f33c4939ba6a0ed437d01cebc6496e43ebd3..1a3bc6cc1c151bc24ee6b87f4d0fd95c98858457 100644 (file)
@@ -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 */
index 96be7ca7143624d9c8c0bf710c37d490f6383df5..854c40926d3f1b0057cb8fd2cab882c24f4db935 100644 (file)
@@ -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<V> * insert(Value data, SPLAYCMP * compare);
 
-    SplayNode<V> * splay(const Value &data, SPLAYCMP * compare) const;
+    template <class FindValue> SplayNode<V> * splay(const FindValue &data, int( * compare)(FindValue const &a, Value const &b)) const;
 };
 
 typedef SplayNode<void *> splayNode;
@@ -86,7 +63,7 @@ public:
     Splay():head(NULL), elements (0){}
 
     mutable SplayNode<V> * head;
-    Value const *find (Value const &, SPLAYCMP *compare) const;
+    template <class FindValue> 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<V>::insert(Value dataToInsert, SPLAYCMP * compare)
 }
 
 template<class V>
+template<class FindValue>
 SplayNode<V> *
-SplayNode<V>::splay(Value const &dataToFind, SPLAYCMP * compare) const
+SplayNode<V>::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<V>::splay(Value const &dataToFind, SPLAYCMP * compare) const
         return NULL;
     }
 
-    SplayNode<V> N(dataToFind);
+    Value temp = Value();
+    SplayNode<V> N(temp);
     SplayNode<V> *l;
     SplayNode<V> *r;
     SplayNode<V> *y;
@@ -308,8 +287,9 @@ SplayNode<V>::splay(Value const &dataToFind, SPLAYCMP * compare) const
 }
 
 template <class V>
+template <class FindValue>
 typename Splay<V>::Value const *
-Splay<V>::find (Value const &value, SPLAYCMP *compare) const
+Splay<V>::find (FindValue const &value, int( * compare)(FindValue const &a, Value const &b)) const
 {
     head = head->splay(value, compare);
 
index 224e820a51c413318432f131bbf00dbe01ad446c..a10faa25bc319a8783cc7a2837149c8564b975de 100644 (file)
@@ -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 \
index c53f49968d8a2963611abc2de79f814dab0c8d71..da84822eb3d4bb5eaef90ae923c75aa4c02234b2 100644 (file)
@@ -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
 #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
index 73ada954a9820f06f8da09d179c12ea4485a2b9a..a193a8937cc1912393333ce94e1ce3c181a737dd 100644 (file)
@@ -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);
index fb5cbe0844049bedfb7a6e25024f973b7653d428..b7909cc6893d557be8acf3d1ba3d9756b6a768b6 100644 (file)
--- 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 */
index 86cbd9fd533de05e5c207b30b089b6997294fbdd..10e42042e685da856e87ac1c6024fd1d15850bdb 100644 (file)
@@ -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)
index 6e6a77420371eebda51735d42485498b56d3df7c..050e464380c9c78e10aaf365e8202e7693131bae 100644 (file)
@@ -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<acl_arp_data *> *data;
     char const *class_;
 };
 
+MEMPROXY_CLASS_INLINE(ACLARP)
+
 #endif /* SQUID_ACLARP_H */
index b848ed4c98c54dece38ec41360ec4ab75da3ec03..a09325ce114fb098b6c716cdd4e217f577767e13 100644 (file)
@@ -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<struct in_addr>
 {
 
 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<struct in_addr> SourceRegistryEntry_;
     static ACL::Prototype DestinationRegistryProtoype;
@@ -68,4 +66,6 @@ private:
     List<int> *data;
 };
 
+MEMPROXY_CLASS_INLINE(ACLASN)
+
 #endif /* SQUID_ACLASN_H */
index c605fe40340a5bef2a5f362672e39a4036a82dfc..1c04cb5c22efd4005cc0f333ddc79f9af6933a5f 100644 (file)
@@ -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
 #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)
 {}
 
index e0e62a1b1b4f50431cf4832c31d71a0db87c4c8e..bf98c0f5343a5e82115aeff7d5a49ff3f6cb233b 100644 (file)
@@ -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<SSL *>
 {
 
 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 */
index 48be437bd475f9adf022c892c4f4d436fdfa89b5..32b30072e90ccce30e4515c39daa341df4f401e5 100644 (file)
@@ -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
 #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;
index 5676425b59b15b45ef5911a46ef72ce0d95741c4..9cc1c5a6161e99dcf2cc98f1dab8f742de237de0 100644 (file)
@@ -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 *> *, 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 */
index f497cdf58bb6760af6d9403df440dcc7a0b3e264..d808144fe55bfd5a64626b2ab4cbc28f5cc052d9 100644 (file)
 #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
 {
index 6ee0dc56bfa10e5ba370f3e21da89b25c92a907a..55b956eb0f096ece298f30f88d4d578baf08a4f8 100644 (file)
@@ -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 */
index 186138a45266ee1c068e3cf2dd7e9a24b55e1f64..499a417862296581b46d64742ae6651176d0383c 100644 (file)
@@ -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
 #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<class T>
 inline void
 xRefFree(T &thing)
index c90ac8157a15ec0d214ab39afbf37cd668785776..23b531ef04678c64f53e45d97be31e4f17208fe5 100644 (file)
@@ -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<char const *>
 {
 
 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<char const *> *clone() const;
 
     SplayNode<char *> *domains;
-
-private:
-    static MemPool *Pool;
 };
 
+MEMPROXY_CLASS_INLINE(ACLDomainData)
+
 #endif /* SQUID_ACLDOMAINDATA_H */
index a38e8ebcaa2a5d2751cba3ccb91e8d29dfcc4161..01adcd77bd8227a81fe40f0477f38090f15746c5 100644 (file)
@@ -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
 #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;
index 34c9de51f2d0c2bb31b689d1055bc7c3f0740e7a..44482e1fe48737a9dab7ac7bc9d2fae7d87ca9bf 100644 (file)
@@ -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<char const *> *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 */
index c2c7a025cdb139400d614d92e169843c7708aa6f..aa807c4c25abef3e9819f598bf9ea1dae934126c 100644 (file)
@@ -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){}
index 83293c331c9feec0623a72a4399bb8c13a37e07a..dc447a3419aec2d6775d9501bfe51dce4559dc8e 100644 (file)
@@ -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
 {
 
index 44b72a8f7f50ac7df92b198d399bff3db309085c..835594428c691d6b5f7fa583b59902d4829c372e 100644 (file)
 #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;
index e0dfe65b1f4e7f37389c38d92eba8ec2fded4b4d..cb035a4c7fcbe307a28764cbbaeaa583b40a8415 100644 (file)
@@ -55,8 +55,7 @@ class ACLIdent : public ACL
 {
 
 public:
-    void *operator new(size_t);
-    void operator delete(void *);
+    MEMPROXY_CLASS(ACLIdent);
 
     ACLIdent(ACLData<char const *> *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 */
index 2788c7cf5a116b80246a49163883aa98477c08b3..e54726c3bcace5fa7fd4ee3e6ff14c734aad214c 100644 (file)
@@ -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()
 {}
 
index 066ab042e47e8b980a266c5efc02f40d25ba30c2..384df07b41b3311e2b61832fef6f38a47ebed695 100644 (file)
@@ -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 */
index 62226694b456a6a9996f3c7a542cf6fa132fbd8b..a8b5565e7a395a16aa1dec1133148d93d99d10d1 100644 (file)
@@ -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()
 {}
 
index 353f35ebffeb21e8c6476b124c69ca09fdfac03f..ddc58382199f258f144e95b525d6f8a0d29d89d9 100644 (file)
@@ -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 */
index 048e2d17c7dae95be01a1cd46687ad2213767f1a..d3551991489b6c67354720b7f1da4d33832d5ab4 100644 (file)
@@ -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
 #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)
 {}
 
index 97ec7d9fe81e6603a7d2def74fb24d14434271e5..24ad5d540e63023309b8ece97bca7e580fbb70d1 100644 (file)
@@ -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<method_t>
 {
 
 public:
-    void *operator new(size_t);
-    void operator delete(void *);
+    MEMPROXY_CLASS(ACLMethodData);
 
     ACLMethodData();
     ACLMethodData(ACLMethodData const &);
@@ -56,9 +55,8 @@ public:
     virtual ACLData<method_t> *clone() const;
 
     List<method_t> *values;
-
-private:
-    static MemPool *Pool;
 };
 
+MEMPROXY_CLASS_INLINE(ACLMethodData)
+
 #endif /* SQUID_ACLMETHODDATA_H */
index 1306b0e2c6a101a509d2620417d367a29da90689..bd8b449c9dd10db56c4d255322919ad5e1035711 100644 (file)
 #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
 {
index dfe289eb059e2c279465ac9ee1f048a48174276a..ae7c3145f9cacf897402a4d854146e30c5e3a30d 100644 (file)
@@ -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 */
index 3b9907ea02a645502c78e020cf100650892743cd..60486f77726e838e692c84c6ddfe1a0c6b171db7 100644 (file)
@@ -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
 #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)
 {}
 
index 23db7afee031f170b5c536c4f5bf969f478af462..04148664682a2ae19e1ac76761fad3f62c4cda80 100644 (file)
@@ -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<protocol_t>
 {
 
 public:
-    void *operator new(size_t);
-    void operator delete(void *);
+    MEMPROXY_CLASS(ACLProtocolData);
 
     ACLProtocolData();
     ACLProtocolData(ACLProtocolData const &);
@@ -56,9 +55,8 @@ public:
     virtual ACLData<protocol_t> *clone() const;
 
     List<protocol_t> *values;
-
-private:
-    static MemPool *Pool;
 };
 
+MEMPROXY_CLASS_INLINE(ACLProtocolData);
+
 #endif /* SQUID_ACLPROTOCOLDATA_H */
index c3a85da434c04a2e431ca1dc6c9e450c83c972a4..40d2bd1faf165af8e8760a8a50ac0a54ef2526a7 100644 (file)
 #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;
index 53d663d4b6f68a0e871a78fda47bbba59018ebf9..bb5ee605610e6b2c8656ffb12702d226014b040d 100644 (file)
@@ -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 *> *, 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 */
index b1dedee817923a4f9bd349a0101035c447422e5e..15ac98103c38a58cc1fc347e9eef5b73fb5798c7 100644 (file)
@@ -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
 #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)
index ca84ffdd51f7332b59243c228a585efa131ddaa9..a9716c7109a1c1981b26348537a790143a360408 100644 (file)
@@ -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<char const *>
 {
 
 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<char const *> *clone() const;
 
 private:
-    static MemPool *Pool;
     relist *data;
 };
 
+MEMPROXY_CLASS_INLINE(ACLRegexData)
+
 #endif /* SQUID_ACLREGEXDATA_H */
index 283bd8ba6e4899020078ae007f7c0a15a792adca..1ccf86e815450e4be41e80682217a0c684e06793 100644 (file)
 #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
 {
index 9f3690c049170656a28b7aa6e7b1bb8f82a4fea4..e1e21cbe7af74e7ddbe13b6a84c4bed608d569e5 100644 (file)
@@ -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 */
index c98ddfd4e1d7742111b7580978a56851b23448e4..f672e91e02d9816349016b293b79906e3a2b786b 100644 (file)
@@ -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<MatchType> *data;
     char const *type_;
     ACLStrategy<MatchType> *matcher;
@@ -76,7 +76,7 @@ private:
 /* implementation follows */
 
 template <class MatchType>
-MemPool *ACLStrategised<MatchType>::Pool = NULL;
+MemAllocator *ACLStrategised<MatchType>::Pool = NULL;
 
 template <class MatchType>
 void *
@@ -86,16 +86,16 @@ ACLStrategised<MatchType>::operator new (size_t byteCount)
     assert (byteCount == sizeof (ACLStrategised<MatchType>));
 
     if (!Pool)
-        Pool = memPoolCreate("ACLStrategised", sizeof (ACLStrategised<MatchType>));
+        Pool = MemPools::GetInstance().create("ACLStrategised", sizeof (ACLStrategised<MatchType>));
 
-    return memPoolAlloc(Pool);
+    return Pool->alloc();
 }
 
 template <class MatchType>
 void
 ACLStrategised<MatchType>::operator delete (void *address)
 {
-    memPoolFree (Pool, address);
+    Pool->free(address);
 }
 
 template <class MatchType>
index 99ad86b27a9aa194350b617e34d109493a8bcd74..9afa52344985d910b2e76dd163f09820c1fdc757 100644 (file)
@@ -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
 #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)
 {}
index 9492e5972c1327675a3008cce612caa68a9d6536..33426e6b36d9d2d5d37f4ad3a09fa576a74c4c68 100644 (file)
@@ -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/
 #include "ACL.h"
 #include "ACLData.h"
 
+
 class ACLStringData : public ACLData<char const *>
 {
 
 public:
-    void *operator new(size_t);
-    void operator delete(void *);
+    MEMPROXY_CLASS(ACLStringData);
 
     ACLStringData();
     ACLStringData(ACLStringData const &);
@@ -56,9 +56,10 @@ public:
     virtual ACLData<char const *> *clone() const;
 
     SplayNode<char *> *values;
-
-private:
-    static MemPool *Pool;
 };
 
+/* TODO move into .cci files */
+
+MEMPROXY_CLASS_INLINE(ACLStringData);
+
 #endif /* SQUID_ACLSTRINGDATA_H */
index 2cf21f0ecfbac3beb390e3173ff197babe35b2e6..979795506ccf3a9305437bd00e4699d4ecc5c9aa 100644 (file)
@@ -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
 #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)
index 2cb883af6bd897deee1eb50512465599ac5a22f3..53a1c6048efc9e3ddfee5ad075868a76c5414f18 100644 (file)
@@ -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<time_t>
 {
 
 public:
-    void *operator new(size_t);
-    void operator delete(void *);
+    MEMPROXY_CLASS(ACLTimeData);
 
     ACLTimeData();
     ACLTimeData(ACLTimeData const &);
@@ -56,11 +55,12 @@ public:
     virtual ACLData<time_t> *clone() const;
 
 private:
-    static MemPool *Pool;
     int weekbits;
     int start;
     int stop;
     ACLTimeData *next;
 };
 
+MEMPROXY_CLASS_INLINE(ACLTimeData)
+
 #endif /* SQUID_ACLTIMEDATA_H */
index 1cac6a805b5aad91deab1a9bf9a3ccc8f4b29aee..822f5dcf829e4836c62bcbed9528fac891d36460 100644 (file)
 #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<class T>
 inline void
 xRefFree(T &thing)
index 34cb833ba1a90b1af80bee63087090af1a473809..c5354648be8142b77a6d80f365a231e183189817 100644 (file)
@@ -43,8 +43,7 @@ class ACLUserData : public ACLData<char const *>
 {
 
 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 */
index d74f8b7770a498cf2d47a39d2d16d7f81424bc5d..7124f8b9ab14304a1002e4223fd70cb58c703217 100644 (file)
@@ -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;
index 3a5fdc81521f95433dffa0078a183c8c50bee351..badf8fcfbb13d424fc090fbb86da7e8391434cb2 100644 (file)
@@ -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
 #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)
index fe9b7d45e17d55f0ed5a547e8e6790c9c75c735b..74c53a7a6dc11c42e8b65019ad92438bc33ed937 100644 (file)
@@ -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 */
index 6ee9b89bb76d676d0f4d6a78b383dfa7ce604ac4..19d51989f66aa6e2939288071ca9b49ebac0e741 100644 (file)
@@ -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
 {
index 621a337d966f3733ecd4e921401c91c2262bc1b6..2717155c354e34b3abe2e1faf97d3584b6967634 100644 (file)
@@ -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 */
index 9a4ba939b666f2d05b37e3454c57142c27b72d63..071551c45c7e601f390ab113561d48eae9e1239b 100644 (file)
@@ -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 */
index bfda742099141990ee1b64ada94290bcb3d7b9e5..9c4bbe19235ff7324e556a7d3e176acd79062887 100644 (file)
@@ -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
 
 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)
 {}
 
index 58a27785c0a61b21e69a25a352f819455f8e013f..167263a04267e85a90542d66fed18b62850d6226 100644 (file)
@@ -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 */
index 174ec5b0b4c2e6da5db563ef62e4ab21b64e9c3f..dcc5ff5ac5f088dbb7810c0bcad88b78bc0f9b13 100644 (file)
@@ -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 */
index 1e8d849a2aa6fc89b931daa1a2243a59b20cc95b..1c52ae8a49466af07a0ec5217884d17ecd7fd8e4 100644 (file)
@@ -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)
 {}
 
index 91f573806ce98ab52202da5f2229130b48170a39..49fcd7a4666c7753f6c00e6c98bdaee20b24275a 100644 (file)
@@ -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)
 {
index 8a184fa1d3dadfc8630047f5f23a43fafce2bab6..1022bcdb4b3fddd6bb71a51d98fcce96c2753a55 100644 (file)
@@ -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<ssize_t> 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<HttpHdrRangeSpec *> specs;
 
 private:
-    static MemPool *Pool;
     void getCanonizedSpecs (Vector<HttpHdrRangeSpec *> &copy);
     void merge (Vector<HttpHdrRangeSpec *> &basis);
     ssize_t clen;
 };
 
+MEMPROXY_CLASS_INLINE(HttpHdrRange)
+
 /* data for iterating thru range specs */
 
 class HttpHdrRangeIter
index 515253c086c15a5586941f85e81d7f676870cfb4..7b0468574c539dc74b30bc603546e56822662965 100644 (file)
@@ -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);
-}
index d69bafeacd4688ba4744efd30f044dee7244d348..22b1e7a7422a40aefcce2d7bc96834d46baaea2c 100644 (file)
@@ -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 <CRLF> */
@@ -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 */
index 0011c1ab1ecc13cfe43e8cefc7162f10e2017b84..651c29bf9f752bd9c0fe902492141d7f966ae4a4 100644 (file)
@@ -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
 #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)
 {
index 1e42c7d33b49994a2ed989ef07cc4513673de073..bd8ed8f5805ccfde3e53846de5e51c7f5187eabe 100644 (file)
@@ -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 */
index 77aed17c5fd5e868aff3961ea0ae89aa262191d3..626e66b4693e596a8487b31333ab97f013c2e6ec 100644 (file)
@@ -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;
 }
index 5149d2842ee4a8c2a45856b9a83ac705a7525f8c..54acae461fefd59a19523633331ca754b0ef99d3 100644 (file)
@@ -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 */
index bc58c59428ae8cb6efc5aeab87c93f47f7a54a41..49fa79f7269032326a82a84f36514cfc41b67724 100644 (file)
@@ -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;
 };
index f31513a69df1264b0c7d0f49b0cb1c2e986455d4..2d54c95d41006ace90a286e3a0c8c6ab19b6552a 100644 (file)
@@ -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();
index f16ceff45ec0579508640ed27858a581aebf49d7..cda254811476298b624088882ac5e72d2ac4fcdd 100644 (file)
@@ -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
 #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
 {
index 56a1f5e6952d2660fc0380f4a68703c76eb7ff02..f93433f5268b6f02352225ea1fc48a875a03d41d 100644 (file)
@@ -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 */
index 83363db6ade942bb18fb9e06f78d49913c93af15..010c0963f918935c23e505935cefb2618b183f67 100644 (file)
@@ -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
 #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
 {
index a67c5ea6e66961ee6b82b64dfe213d65bf70619b..df241daa0de48c3fe23b173c9c7122d2500e6673 100644 (file)
@@ -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 */
index 4cc7ee7eb18a4fc81f405333b6fef7e30d9671b7..36f7421e46f6adab68c2f872903ffe5ad5b87600 100644 (file)
@@ -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
 #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
 {
index bb476e6b6058744507c65ce63fe0e6482d81eba4..70a586b40e71a8153681de8ba8e9ad477bbddbb4 100644 (file)
@@ -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 */
index 2a7a1cb07ceabd6d0b25e99d98e61fa0961ed1ca..9cf20edd4c37f1e3c18c46bec30ea02fc0f9a0fa 100644 (file)
@@ -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
 #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
 {
index 0b1d80576bc914a3cd480ac64c7d400c03af9cc5..9372e494c2fdbe3fc16cda0efaeec6385a0429b1 100644 (file)
@@ -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 */
index f8bfc55491cac26424f26bc5b67fabf2c78659c3..18f7917bbf549559094b6d25a6747a45222245f7 100644 (file)
@@ -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);
-}
index 3681fa442be62433eafe380c4375764e9f9bc7c7..507eb39018585f7fdd2f9e276444e7bfdae53cc5 100644 (file)
@@ -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 */
index 2cb8d4b974cd5662a1f3a1e9b5f8569279d4cb10..d97d46b0e0d0f33ed8d0eef1fbd313be2fdb26cc 100644 (file)
@@ -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 *
index 9ba0887940789c193f607aa7fb2307c2b9d09c2d..93c389d7edbce7fe50d7c8af092a900d675ac005 100644 (file)
@@ -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)
index 379a28aa89430002d702c1518c043d2aaaffd913..4dcbbda676cdf47c28597a6db203b065c0a023f2 100644 (file)
@@ -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;
index 05b8462f64fe94e3c368c318b2c2edda4cdfe129..b1438188244859f8569b87431f2aacd5f938064c 100644 (file)
@@ -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<BasicUser *>(aUser);}
 
 private:
-    static MemPool *Pool;
     BasicUser *_theUser;
 };
 
+MEMPROXY_CLASS_INLINE(AuthBasicUserRequest)
+
 /* configuration runtime data */
 
 class AuthBasicConfig : public AuthConfig
index 925251827bfaad9b96184614ff32bd944d5b83ee..c3e3a40802f90de1003174c4242b35d6833a19b8 100644 (file)
@@ -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),
index 0f18747a4afb21be341d0a7ec85a140928fa9a69..9d299fc3f85fbee5f928f5aa7acb1d1f42b28ce5 100644 (file)
@@ -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
index 03922790d0629525ca8e6d977cd32c4af5ebda7f..82a077b453b0b11844ed00d49fc7911c26c83fc3 100644 (file)
@@ -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<ProxyAuthCachePointer *>(memPoolAlloc(ntlm_user_hash_pool));
+    proxy_auth_hash = static_cast<ProxyAuthCachePointer *>(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;
index c48b28e925d504e4436b166784f2549043f6af6c..434c0c9d4497cb0f89bcc5cdc04a95e830468a80 100644 (file)
@@ -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 */
index 7899b1a08ce00e1817f4089153899f9322838e8d..5cbd8ef4202227b1065b6fd4e34d9046e466293d 100644 (file)
@@ -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
 #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<AuthUserHashPointer *>(memPoolAlloc(pool));
-}
-
-void
-AuthUserHashPointer::operator delete (void *address)
-{
-    memPoolFree(pool, address);
-}
-
 AuthUserHashPointer::AuthUserHashPointer (auth_user_t * anAuth_user):
         auth_user (anAuth_user)
 {
index 30866adeb06c48c5597edf047466f3fe17c6fc7f..7c51e098185050999042a6cbdef885555565333b 100644 (file)
@@ -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;
index bc164fdc04253ff9547e96e21b8b6c4b035f4269..644d56bc84a45f223f48b25834e674baa8624217 100644 (file)
@@ -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);
         }
     }
 
index fe6e5aa1764b2952a7fb6d9ccd7180833fd00131..7e9e5b41eb531cd34896eaaa1d3ea8d0fe5a0e44 100644 (file)
@@ -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<IOCB> aCallback, int);
     virtual comm_callback_t getType() const { return COMM_CB_READ; }
 
     virtual void callCallback();
 
 private:
-    static MemPool *Pool;
     CallBack<IOCB> 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<IOACB>, comm_err_t, int, int, ConnectionDetail const &);
     virtual void callCallback();
 
 private:
-    static MemPool *Pool;
     CallBack<IOACB> 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<IOFCB> aCallback, comm_err_t, int);
     virtual void callCallback();
 
 private:
-    static MemPool *Pool;
     CallBack<IOFCB> 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<IOWCB> aCallback, comm_err_t, int, int);
     virtual void callCallback();
 
 private:
-    static MemPool *Pool;
     CallBack<IOWCB> 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;
index a7e0a211d6a65449b8ec5f386a1bc7750aeb3df7..c62511315fafbdb11e624eeb06c2ff4fbbc3a4bf 100644 (file)
@@ -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
 {
index b3f99bac4749591858c8319f2954eec1f35a22dc..618d540ecb5e578a8c92654ef9c580eb9ba06a1e 100644 (file)
@@ -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 <slf@connect.com.au>
@@ -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;
 
index c949b27470c81184d881832042207a947e71fab6..bdc62789b3c2dd49cf2a23f7a96f1bb88cfc55f4 100644 (file)
@@ -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 <pete@demon.net>
@@ -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();
 }
index 743a8af439879dcf5b7ecae77448ae1f1211b1c4..c24a67c0b51b6dfe6d13b885dc164e4250163a8c 100644 (file)
@@ -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;
 }
 
index 4d2e5a375da1cadd480c73c4ded764d674e7c6da..ea887421c9640d2a98f6fc77e8b4503625be6943 100644 (file)
@@ -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
 {
index 9d1f590ffa04006f4b5d31b2b1370bd9e2e7c419..803f453ae178b625d4cb8eb4fc78c1252f2701ed 100644 (file)
@@ -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);
index b86a6471ca356d6e5c14eb2666074282e4f61224..d7e9e5bb7218ac8aa348ed9b4312505fb6269916 100644 (file)
@@ -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)
 {}
 
index ec4311e4a427d5976fe567a3fa237cffda949bf0..fefb273bd93ec62aefc1ab93540ecc543debbdb8 100644 (file)
@@ -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()
 {
index 599c34bbc1090a1a0322cf6cedd1eca0266df8b5..0f60377571a4ce3bf2c2d05554fd3ccbb9939ee4 100644 (file)
@@ -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);
-}
index 639ca1f22087180987784973ec501908193c9855..8c28682f05441b4b207ac9238fea036274717e62 100644 (file)
@@ -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 */
index 99bc6be0df7a6fd609ee45ffc5e080e9483f1429..870d7d5e6b31b7bbbd1cdf93110a1fd1bce31a57 100644 (file)
@@ -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<htcpSpecifier *> (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<htcpDetail *>(memPoolAlloc(htcpDetailPool));
+    htcpDetail *d = static_cast<htcpDetail *>(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));
     }
 }
 
index 930c6b1ea28e1a49c306d77a3dc07fc97c81b95d..2893f5857131ec5850beadfacb9b2313519aaea1 100644 (file)
@@ -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"
index 1ba8ece1f0ef441a8cd9d5d625d9dcfcee7cbcf1..aaebd7186e7379a84d53db2fcc3428e8afa27c28 100644 (file)
@@ -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<time_t>(clean_interval));
+    MemPools::GetInstance().clean(static_cast<time_t>(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++;
index c9d61d960d0f2a6618a71e77c8dc546e0a766b88..788309a8c405ea138c74610b5f68baa117f5d5e8 100644 (file)
@@ -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
 #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;
 }
index 1fe3bd4c0c12d484026309244a4612cf79049913..da43da6168750bde8cfd4195d2f7b00cb0871e7c 100644 (file)
@@ -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)
 {
index c51fa30d35feced7fa335bbeeaaffd14a8c95a93..33b2335d010d293def68fb4843f69ab434f0155a 100644 (file)
@@ -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);
     }
index 38bd516ab5ff212af0468b471d44d06a499cbe50..cd71c66d5b624f9f1d849607bceb1accec8157ad 100644 (file)
@@ -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);
 
 /* ----------------------------------------------------------------- */
 
index 38b276ff0485b684169d0bff063e62eee398e891..8f1ec5e4d3c179ba3b2fb0759038f2ac16441b08 100644 (file)
@@ -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 */
index d00fa10914aee0d68c9f72bdb2b35ce8369791a2..eae12a72699e2cc39f1f2d175bdda55b9aa9f823 100644 (file)
@@ -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 <class V>
+void free(V x) { fatal("Do not use ::free()"); }
+
 #ifndef calloc
 #define calloc +
 #endif
index 621bde64a8ded798a372b2df317880f78add375d..7df3a5ebee5d46a8ce04be749379584f9395a332 100644 (file)
@@ -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<StoreEntry*> 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;
 }
index 7e00dad9035eb37e2a1d5e248eacd3bfb4f7f33a..e56fc483ce60d052e03a59065ffc1758586ce228 100644 (file)
@@ -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<store_client *>(address);
+    cbdataFree(t);
 }
 
 bool
index 0e611db4eded9369faa04d9ef49a575eaee3f7fc..b7c1d1946604177e722f9cb33889af2763667dbc 100644 (file)
@@ -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;
index 4e72d737abb897575cfb4fa9f7d97d1231ea0db1..869b9fc699aafa64231e963691060f355b12bd81 100644 (file)
@@ -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
index 4edf10b85b313773f3fc2e83dbadbe746a7c9cf9..082ebf98a154bf7f4b987d2a6c0cf2842fb7adf2 100644 (file)
@@ -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
 {
 
index 8fa67eef379fd08666b7fd9757610b19dd44b2c0..8aa48ad51e5ea52b0d3e9ad8d96e362ffa7a6ca4 100644 (file)
@@ -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<SomethingToAlloc *>(memPoolAlloc(Pool));
+    SomethingToAlloc *something = static_cast<SomethingToAlloc *>(Pool->alloc());
     assert (something);
     assert (something->aValue == 0);
     something->aValue = 5;
-    memPoolFree (Pool, something);
-    SomethingToAlloc *otherthing = static_cast<SomethingToAlloc *>(memPoolAlloc (Pool));
+    Pool->free(something);
+    SomethingToAlloc *otherthing = static_cast<SomethingToAlloc *>(Pool->alloc());
     assert (otherthing == something);
     assert (otherthing->aValue == 0);
-    memPoolFree (Pool, otherthing);
-    memPoolDestroy (&Pool);
+    Pool->free (otherthing);
+    delete Pool;
 }
 
 int
index 0ee0613b86c42bf36d9e44d7efa00411cc21b604..1b9085a1516f01c8772e8b3763d77b3fe009b16a 100644 (file)
@@ -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 */
index 8a3c73d4c831054dc1d249377dd3587337590216..f3d6fef39a40252895b682acbea6d1faee0b9c67 100644 (file)
@@ -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 *>(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