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
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
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])
/*
- * $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/
private:
CBDATA_CLASS(List);
-#if 0
-
- static MemPool *Pool;
-#endif
};
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);
void
List<C>::operator delete (void *address)
{
- // MemPoolFree
- // List<C> *t = static_cast<List<C> *>(address);
cbdataFree(address);
}
#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>
#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 )
#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;
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;
#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_ */
#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 */
/*
- * $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"
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;
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
}
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 :} */
return NULL;
}
- SplayNode<V> N(dataToFind);
+ Value temp = Value();
+ SplayNode<V> N(temp);
SplayNode<V> *l;
SplayNode<V> *r;
SplayNode<V> *y;
}
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);
## 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
Profiler.c \
snprintf.c
libmiscutil_a_SOURCES = \
- MemPool.c \
+ MemPool.cc \
base64.c \
getfullhostname.c \
hash.c \
/*
- * $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
/*
- * $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"
*/
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);
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLList);
ACLList();
void negated(bool isNegated);
int op;
ACL *_acl;
ACLList *next;
-
-private:
- static MemPool *Pool;
};
+MEMPROXY_CLASS_INLINE(ACLList)
+
typedef ACLList acl_list;
#endif /* SQUID_ACL_H */
/*
- * $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
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)
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLARP);
ACLARP(char const *);
ACLARP(ACLARP const &);
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 */
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLASN);
virtual ~ACLASN();
virtual void prepareForUse();
private:
- static MemPool *Pool;
static ACL::Prototype SourceRegistryProtoype;
static ACLStrategised<struct in_addr> SourceRegistryEntry_;
static ACL::Prototype DestinationRegistryProtoype;
List<int> *data;
};
+MEMPROXY_CLASS_INLINE(ACLASN)
+
#endif /* SQUID_ACLASN_H */
/*
- * $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)
{}
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLCertificateData);
ACLCertificateData(SSLGETATTRIBUTE *);
ACLCertificateData(ACLCertificateData const &);
ACLStringData values;
private:
- static MemPool *Pool;
SSLGETATTRIBUTE *sslAttributeCall;
};
+MEMPROXY_CLASS_INLINE(ACLCertificateData)
+
#endif /* SQUID_ACLCERTIFICATEDATA_H */
/*
- * $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;
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLDestinationDomain);
~ACLDestinationDomain();
ACLDestinationDomain(ACLData<char const *> *, char const *);
virtual ACL *clone()const;
private:
- static MemPool *Pool;
static Prototype LiteralRegistryProtoype;
static Prototype LegacyRegistryProtoype;
static ACLDestinationDomain LiteralRegistryEntry_;
char const *type_;
};
+MEMPROXY_CLASS_INLINE(ACLDestinationDomain)
+
#endif /* SQUID_ACLDESTINATIONDOMAIN_H */
#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
{
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLDestinationIP);
virtual char const *typeString() const;
virtual int match(ACLChecklist *checklist);
virtual ACL *clone()const;
private:
- static MemPool *Pool;
static Prototype RegistryProtoype;
static ACLDestinationIP RegistryEntry_;
};
+MEMPROXY_CLASS_INLINE(ACLDestinationIP)
+
#endif /* SQUID_ACLDESTINATIONIP_H */
/*
- * $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)
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLDomainData);
virtual ~ACLDomainData();
bool match(char const *);
virtual ACLData<char const *> *clone() const;
SplayNode<char *> *domains;
-
-private:
- static MemPool *Pool;
};
+MEMPROXY_CLASS_INLINE(ACLDomainData)
+
#endif /* SQUID_ACLDOMAINDATA_H */
/*
- * $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;
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLExtUser);
ACLExtUser(ACLData<char const *> *newData, char const *);
ACLExtUser (ACLExtUser const &old);
virtual ACL *clone()const;
private:
- static MemPool *Pool;
static Prototype UserRegistryProtoype;
static ACLExtUser UserRegistryEntry_;
static Prototype RegexRegistryProtoype;
char const *type_;
};
+MEMPROXY_CLASS_INLINE(ACLExtUser)
+
#endif /* SQUID_ACLIDENT_H */
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){}
{
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);
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
{
#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;
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLIdent);
ACLIdent(ACLData<char const *> *newData, char const *);
ACLIdent (ACLIdent const &old);
virtual ACL *clone()const;
private:
- static MemPool *Pool;
static Prototype UserRegistryProtoype;
static ACLIdent UserRegistryEntry_;
static Prototype RegexRegistryProtoype;
char const *type_;
};
+MEMPROXY_CLASS_INLINE(ACLIdent)
+
#endif /* SQUID_ACLIDENT_H */
/*
- * $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
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()
{}
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLMaxConnection);
ACLMaxConnection(char const *);
ACLMaxConnection(ACLMaxConnection const &);
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 */
/*
- * $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
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()
{}
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLMaxUserIP);
ACLMaxUserIP(char const *);
ACLMaxUserIP(ACLMaxUserIP const &);
virtual bool requiresRequest() const {return true;}
private:
- static MemPool *Pool;
static Prototype RegistryProtoype;
static ACLMaxUserIP RegistryEntry_;
flags;
};
+MEMPROXY_CLASS_INLINE(ACLMaxUserIP)
+
#endif /* SQUID_ACLMAXUSERIP_H */
/*
- * $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)
{}
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLMethodData);
ACLMethodData();
ACLMethodData(ACLMethodData const &);
virtual ACLData<method_t> *clone() const;
List<method_t> *values;
-
-private:
- static MemPool *Pool;
};
+MEMPROXY_CLASS_INLINE(ACLMethodData)
+
#endif /* SQUID_ACLMETHODDATA_H */
#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
{
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLMyIP);
static ACLMyIP const &RegistryEntry();
virtual char const *typeString() const;
virtual ACL *clone()const;
private:
- static MemPool *Pool;
static Prototype RegistryProtoype;
static ACLMyIP RegistryEntry_;
};
+MEMPROXY_CLASS_INLINE(ACLMyIP)
+
#endif /* SQUID_ACLMYIP_H */
/*
- * $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)
{}
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLProtocolData);
ACLProtocolData();
ACLProtocolData(ACLProtocolData const &);
virtual ACLData<protocol_t> *clone() const;
List<protocol_t> *values;
-
-private:
- static MemPool *Pool;
};
+MEMPROXY_CLASS_INLINE(ACLProtocolData);
+
#endif /* SQUID_ACLPROTOCOLDATA_H */
#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;
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLProxyAuth);
~ACLProxyAuth();
ACLProxyAuth(ACLData<char const *> *, char const *);
virtual int matchForCache(ACLChecklist *checklist);
private:
- static MemPool *Pool;
static Prototype UserRegistryProtoype;
static ACLProxyAuth UserRegistryEntry_;
static Prototype RegexRegistryProtoype;
char const *type_;
};
+MEMPROXY_CLASS_INLINE(ACLProxyAuth)
+
#endif /* SQUID_ACLPROXYAUTH_H */
/*
- * $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)
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLRegexData);
virtual ~ACLRegexData();
virtual bool match(char const *user);
virtual ACLData<char const *> *clone() const;
private:
- static MemPool *Pool;
relist *data;
};
+MEMPROXY_CLASS_INLINE(ACLRegexData)
+
#endif /* SQUID_ACLREGEXDATA_H */
#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
{
{
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 */
/*
- * $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/
virtual ACL *clone()const;
private:
- static MemPool *Pool;
+ static MemAllocator *Pool;
ACLData<MatchType> *data;
char const *type_;
ACLStrategy<MatchType> *matcher;
/* implementation follows */
template <class MatchType>
-MemPool *ACLStrategised<MatchType>::Pool = NULL;
+MemAllocator *ACLStrategised<MatchType>::Pool = NULL;
template <class MatchType>
void *
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>
/*
- * $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)
{}
/*
- * $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 &);
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 */
/*
- * $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)
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLTimeData);
ACLTimeData();
ACLTimeData(ACLTimeData const &);
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 */
#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)
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLUserData);
virtual ~ACLUserData();
bool match(char const *user);
}
flags;
-
-private:
- static MemPool *Pool;
};
+MEMPROXY_CLASS_INLINE(ACLUserData)
+
#endif /* SQUID_ACLUSERDATA_H */
/*
- * $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
struct esiComment : public ESIElement
{
- void *operator new (size_t byteCount);
- void operator delete (void *address);
+ MEMPROXY_CLASS(esiComment);
~esiComment();
esiComment();
Pointer makeCacheable() const;
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"
struct esiTry : public ESIElement
{
- void *operator new (size_t byteCount);
- void operator delete (void *address);
+ MEMPROXY_CLASS(esiTry);
esiTry(esiTreeParentPtr aParent);
~esiTry();
void finish();
private:
- static MemPool *Pool;
void notifyParent();
esiTreeParentPtr parent;
ESISegment::Pointer exceptbuffer;
esiProcessResult_t bestAttemptRV() const;
};
-MemPool *esiTry::Pool = NULL;
+MEMPROXY_CLASS_INLINE(esiTry)
#include "ESIVar.h"
struct esiChoose : public ESIElement
{
- void *operator new (size_t byteCount);
- void operator delete (void *address);
+ MEMPROXY_CLASS(esiChoose);
esiChoose(esiTreeParentPtr);
~esiChoose();
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;
void setTestResult(bool aBool) {testValue = aBool;}
private:
- static MemPool *Pool;
esiWhen (esiWhen const &);
bool testValue;
char const *unevaluatedExpression;
void evaluate();
};
-MemPool *esiWhen::Pool = NULL;
+MEMPROXY_CLASS_INLINE(esiWhen)
/* esiOtherwise */
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()
{}
}
/* 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);
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)
{}
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)
{}
}
/* 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;
/*
- * $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)
/*
- * $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
{
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 &);
void finish();
private:
- static MemPool *Pool;
void evaluateVariable();
esiTreeParentPtr parent;
ESIVarState *varState;
String unevaluatedVariable;
};
+MEMPROXY_CLASS_INLINE(ESIAssign)
+
#endif /* SQUID_ESIASSIGN_H */
/*
- * $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
CBDATA_CLASS_INIT (ESIStreamContext);
-MemPool *ESIInclude::Pool = NULL;
-
/* other */
static CSCB esiBufferRecipient;
static CSD esiBufferDetach;
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
{
/*
- * $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
{
public:
- void *operator new (size_t byteCount);
- void operator delete (void *address);
+ MEMPROXY_CLASS(ESIInclude);
ESIInclude(esiTreeParentPtr, int attributes, const char **attr, ESIContext *);
~ESIInclude();
void finish();
private:
- static MemPool *Pool;
void Start (ESIStreamContext::Pointer, char const *, ESIVarState *);
esiTreeParentPtr parent;
void start();
void prepareRequestHeaders(HttpHeader &tempheaders, ESIVarState *vars);
};
+MEMPROXY_CLASS_INLINE(ESIInclude)
+
#endif /* SQUID_ESIINCLUDE_H */
/*
- * $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
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);
void finish();
private:
- static MemPool *pool;
esiLiteral(esiLiteral const &);
};
+MEMPROXY_CLASS_INLINE(esiLiteral)
+
#endif /* SQUID_ESILITERAL_H */
/*
- * $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)
{}
/*
- * $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
{
public:
- void *operator new (size_t byteCount);
- void operator delete (void *address);
+ MEMPROXY_CLASS(esiSequence);
esiSequence(esiTreeParentPtr, bool = false);
~esiSequence();
esiTreeParentPtr parent;
private:
- static MemPool *Pool;
int elementIndex (ESIElement::Pointer anElement) const;
bool mayFail_;
bool failed;
void processStep(int dovars);
};
+MEMPROXY_CLASS_INLINE(esiSequence)
+
#endif /* SQUID_ESISEQUENCE_H */
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(ACLExternal);
static void ExternalAclLookup(ACLChecklist * ch, ACLExternal *, EAH * callback, void *callback_data);
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 */
/*
- * $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
* 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 */
* 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)
{}
/*
- * $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
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)
{
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete (void *);
+ MEMPROXY_CLASS(HttpHdrRangeSpec);
typedef Range<ssize_t> HttpRange;
static ssize_t const UnknownPosition;
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.
{
public:
- void *operator new(size_t);
- void operator delete (void *);
+ MEMPROXY_CLASS(HttpHdrRange);
static size_t ParsedCount;
/* Http Range Header Field */
Vector<HttpHdrRangeSpec *> specs;
private:
- static MemPool *Pool;
void getCanonizedSpecs (Vector<HttpHdrRangeSpec *> ©);
void merge (Vector<HttpHdrRangeSpec *> &basis);
ssize_t clen;
};
+MEMPROXY_CLASS_INLINE(HttpHdrRange)
+
/* data for iterating thru range specs */
class HttpHdrRangeIter
/*
- * $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
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);
-}
/*
- * $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/
{
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> */
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 */
/*
- * $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)
{
/*
- * $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/
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(HttpRequest);
HttpRequest();
virtual ~HttpRequest() {}
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 */
/*
- * $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
#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;
}
/*
- * $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/
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();
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 */
/*
- * $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/
#endif
private:
- static MemPool *pool;
+ static MemImplementingAllocator *pool;
bool validLength() const;
};
/*
- * $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/
public:
void *operator new (size_t);
- void operator delete(void *);
+ void operator delete (void *);
store_client(StoreEntry *);
~store_client();
bool memReaderHasLowerOffset(off_t) const;
StoreIOBuffer copyInto;
private:
- static MemPool *pool;
-
+ CBDATA_CLASS(store_client);
void fileRead();
void scheduleDiskRead();
void scheduleMemRead();
/*
- * $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
{
/*
- * $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/
{
public:
- void *operator new (size_t);
- void operator delete (void *);
+ MEMPROXY_CLASS(StoreMetaMD5);
char getType() const {return STORE_META_KEY_MD5;}
bool checkConsistency(StoreEntry *) const;
private:
- static MemPool *pool;
static int md5_mismatches;
};
+MEMPROXY_CLASS_INLINE(StoreMetaMD5)
+
#endif /* SQUID_STOREMETAMD5_H */
/*
- * $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
{
/*
- * $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/
{
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 */
/*
- * $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
{
/*
- * $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/
{
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 */
/*
- * $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
{
/*
- * $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/
{
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 */
/*
- * $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
{
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);
-}
/*
- * $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/
* ----------------------------------------------------------
{
public:
- void *operator new (size_t byteCount);
- void operator delete (void *address);
+ MEMPROXY_CLASS(StoreSwapLogData);
StoreSwapLogData();
char op;
sfileno swap_filen;
u_short refcount;
u_short flags;
unsigned char key[MD5_DIGEST_CHARS];
-
-private:
- static MemPool *Pool;
};
+MEMPROXY_CLASS_INLINE(StoreSwapLogData)
+
#endif /* SQUID_STORESWAPLOGDATA_H */
/*
- * $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
/* 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 *
/*
- * $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
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)
/*
- * $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
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)
{}
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;
{
public:
+ MEMPROXY_CLASS(BasicUser);
+
virtual void deleteSelf() const;
- void *operator new(size_t);
- void operator delete (void *);
BasicUser(AuthConfig *);
~BasicUser();
bool authenticated() const;
BasicAuthQueueNode *auth_queue;
private:
- static MemPool *Pool;
void decodeCleartext();
void extractUsername();
void extractPassword();
char const *httpAuthHeader;
};
+MEMPROXY_CLASS_INLINE(BasicUser)
+
typedef class BasicUser basic_data;
/* follows the http request around */
{
public:
- void *operator new (size_t);
- void operator delete (void *);
+ MEMPROXY_CLASS(AuthBasicUserRequest);
+
AuthBasicUserRequest();
virtual ~AuthBasicUserRequest();
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
/*
- * $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
static AuthDigestConfig digestConfig;
static int authdigest_initialised = 0;
-static MemPool *digest_nonce_pool = NULL;
+static MemAllocatorProxy *digest_nonce_pool = NULL;
CBDATA_TYPE(DigestAuthenticateStateData);
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
safe_free(nonce->key);
- memPoolFree(digest_nonce_pool, nonce);
+ digest_nonce_pool->free(nonce);
}
}
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);
#if DEBUGSHUTDOWN
if (digest_nonce_pool) {
- memPoolDestroy(&digest_nonce_pool);
+ delete digest_nonce_pool;
+ digest_nonce_pool = NULL;
}
#endif
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)
{}
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),
{
public:
- void *operator new(size_t);
- void operator delete (void *);
+ MEMPROXY_CLASS(DigestUser);
DigestUser(AuthConfig *);
~DigestUser();
/* 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 */
public:
enum CredentialsState {Unchecked, Ok, Pending, Failed};
- void *operator new(size_t);
- void operator delete (void *);
+ MEMPROXY_CLASS(AuthDigestUserRequest);
AuthDigestUserRequest();
virtual ~AuthDigestUserRequest();
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
/*
- * $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
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;
#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");
}
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;
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);
}
}
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);
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)
}
}
-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;
{
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();
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 */
/*
- * $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
*/
}
-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)
{
/*
- * $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/
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;
/*
- * $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
struct CBDataIndex
{
- MemPool *pool;
+ MemAllocatorProxy *pool;
FREE *free_func;
}
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;
}
{
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;
* 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;
}
* 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
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);
}
}
/*
- * $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
{
public:
- void *operator new(size_t);
- void operator delete(void *);
+ MEMPROXY_CLASS(CommCallbackData);
CommCallbackData(CommCommonCallback const &);
virtual ~CommCallbackData() {}
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;
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;
/* 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);
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. */
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);
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);
cbdataReferenceDone(p->data);
- memPoolFree(conn_close_pool, p);
+ conn_close_pool->free(p);
}
static 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. */
* 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;
/*
- * $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
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
{
/*
- * $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>
#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
#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)
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);
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);
}
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);
}
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;
}
/* 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;
}
resultp->aio_errno = requestp->err;
}
- memPoolFree(squidaio_request_pool, requestp);
+ squidaio_request_pool->free(requestp);
} /* squidaio_cleanup_request */
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);
if (!squidaio_initialised)
squidaio_init();
- requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool);
+ requestp = (squidaio_request_t *)squidaio_request_pool->alloc();
requestp->fd = fd;
if (!squidaio_initialised)
squidaio_init();
- requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool);
+ requestp = (squidaio_request_t *)squidaio_request_pool->alloc();
requestp->fd = fd;
if (!squidaio_initialised)
squidaio_init();
- requestp = (squidaio_request_t *)memPoolAlloc(squidaio_request_pool);
+ requestp = (squidaio_request_t *)squidaio_request_pool->alloc();
requestp->fd = fd;
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);
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);
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);
if (!squidaio_initialised)
squidaio_init();
- requestp = memPoolAlloc(squidaio_request_pool);
+ requestp = squidaio_request_pool->alloc();
resultp->result_type = _AIO_OP_OPENDIR;
/*
- * $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>
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
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);
if (!initialised)
return;
- memPoolDestroy(&squidaio_ctrl_pool);
+ delete squidaio_ctrl_pool;
+
+ squidaio_ctrl_pool = NULL;
initialised = false;
}
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);
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;
}
dlinkDelete(m, &used_list);
- memPoolFree(squidaio_ctrl_pool, ctrlp);
+ squidaio_ctrl_pool->free(ctrlp);
}
}
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);
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);
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);
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);
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);
if (ctrlp->operation == _AIO_CLOSE)
aioFDWasClosed(ctrlp->fd);
- memPoolFree(squidaio_ctrl_pool, ctrlp);
+ squidaio_ctrl_pool->free(ctrlp);
}
return retval;
int
aioQueueSize(void)
{
- return memPoolInUseCount(squidaio_ctrl_pool);
+ return squidaio_ctrl_pool->inUseCount();
}
/*
- * $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
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;
}
{
assert(!initialised);
- coss_index_pool = memPoolCreate("COSS index data", sizeof(CossIndexNode));
+ coss_index_pool = new MemAllocatorProxy("COSS index data", sizeof(CossIndexNode));
initialised = true;
}
{
public:
- void * operator new (size_t);
- void operator delete (void *);
+ MEMPROXY_CLASS(CossState);
CossState(CossSwapDir *);
~CossState();
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
{
/*
- * $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
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;
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);
/*
- * $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
/* === 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)
{}
/*
- * $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
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)
{
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()
{
/*
- * $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?
srv->parent = cbdataReference(hlp);
if (hlp->datapool != NULL)
- srv->data = memPoolAlloc(hlp->datapool);
+ srv->data = hlp->datapool->alloc();
dlinkAddTail(srv, &srv->link, &hlp->servers);
}
if (srv->data != NULL)
- memPoolFree(hlp->datapool, srv->data);
+ hlp->datapool->free(srv->data);
cbdataReferenceDone(srv->parent);
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)
{
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);
-}
/*
- * $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?
{
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 */
/*
- * $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
{
public:
- void *operator new (unsigned int byteCount);
- void operator delete (void *address);
+ MEMPROXY_CLASS(htcpSpecifier);
void created (StoreEntry *newEntry);
void checkHit();
char *req_hdrs;
private:
- static MemPool *pool;
HttpRequest *checkHitRequest;
struct sockaddr_in *from;
htcpDataHeader *dhdr;
};
+MEMPROXY_CLASS_INLINE(htcpSpecifier)
+
struct _htcpDetail
{
char *resp_hdrs;
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);
* 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)
safe_free(d->resp_hdrs);
safe_free(d->entity_hdrs);
safe_free(d->cache_hdrs);
- memPoolFree(htcpDetailPool, d);
+ htcpDetailPool->free(d);
}
static int
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);
}
if (!htcpDetailPool) {
- htcpDetailPool = memPoolCreate("htcpDetail", sizeof(htcpDetail));
+ htcpDetailPool = MemPools::GetInstance().create("htcpDetail", sizeof(htcpDetail));
}
}
/*
- * $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
{
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"
/*
- * $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
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;
static struct
{
- MemPool *pool;
+ MemAllocator *pool;
}
StrPools[mem_str_pool_count];
/* 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 */
* 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
{
assert(name && size);
assert(MemPools[type] == NULL);
- MemPools[type] = memPoolCreate(name, size);
+ MemPools[type] = MemPools::GetInstance().create(name, size);
}
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 */
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++) {
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();
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++) {
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 */
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)
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 */
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));
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",
#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",
memClean(void)
{
MemPoolGlobalStats stats;
- memPoolSetIdleLimit(0);
- memPoolClean(0);
+ MemPools::GetInstance().setIdleLimit(0);
+ MemPools::GetInstance().clean(0);
memPoolGetGlobalStats(&stats);
if (stats.tot_items_inuse)
static MemPoolGlobalStats mp_total;
int not_used = 0;
MemPoolIterator *iter;
- MemPool *pool;
+ MemAllocator *pool;
/* caption */
storeAppendPrintf(e, "Current memory usage:\n");
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++;
/*
- * $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)
{}
size_t
mem_node::InUseCount()
{
- if (!pool)
- return 0;
-
MemPoolStats stats;
- memPoolGetStats (&stats, pool);
+ Pool().getStats (&stats);
return stats.items_inuse;
}
/*
- * $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/
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;
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)
{
/*
- * $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
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);
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;
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);
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",
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);
}
/*
- * $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/
#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);
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);
/* ----------------------------------------------------------------- */
/*
- * $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
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;
dlinkDelete(&lru_node->node, &lru->list);
- memPoolFree(lru_node_pool, lru_node);
+ lru_node_pool->free(lru_node);
lru->count -= 1;
}
goto try_again;
}
- memPoolFree(lru_node_pool, lru_node);
+ lru_node_pool->free(lru_node);
lru->count -= 1;
lru->setPolicyNode(entry, NULL);
return entry;
/* 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 */
/*
- * $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
*
#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
/*
- * $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
* local variables
*/
static Stack<StoreEntry*> LateReleaseStack;
-MemPool *StoreEntry::pool = NULL;
+MemImplementingAllocator *StoreEntry::pool = NULL;
void *
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
MemPoolStats stats;
- memPoolGetStats (&stats, pool);
+ pool->getStats (&stats);
return stats.items_inuse;
}
/*
- * $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
#endif
#include "HttpRequest.h"
-CBDATA_TYPE(store_client);
-
/*
* NOTE: 'Header' refers to the swapfile metadata header.
* 'OBJHeader' refers to the object header, with cannonical
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
/*
- * $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/
{
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
int n_to_start;
int n_running;
int ipc_type;
- MemPool *datapool;
+ MemAllocatorProxy *datapool;
HLPSAVAIL *IsAvailable;
HLPSONEQ *OnEmptyQueue;
time_t last_queue_warn;
/*
- * $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
SQUIDCEXTERN void (*failure_notify) (const char *);
-MemPool *dlink_node_pool = NULL;
+MemAllocator *dlink_node_pool = NULL;
void
releaseServerSockets(void)
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 */
if (m == NULL)
return;
- memPoolFree(dlink_node_pool, m);
+ dlink_node_pool->free(m);
}
void
/*
- * $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/
* ----------------------------------------------------------
{
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 */
void openDone();
};
+MEMPROXY_CLASS_INLINE(UFSStoreState::_queued_read)
+MEMPROXY_CLASS_INLINE(UFSStoreState::_queued_write)
+
class RebuildState : public RefCountable
{
/*
- * $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
*
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
/*
- * $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
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 */
safeTop->destroy(destint);
/* check we don't segfault on NULL splay calls */
safeTop = NULL;
- safeTop->splay(NULL, compareint);
+ safeTop->splay((intnode *)NULL, compareint);
}
{
/* intnode */
/*
- * $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
*
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 */
if (m == NULL)
return;
- memPoolFree(dlink_node_pool, m);
+ dlink_node_pool->free(m);
}
void