From: Amos Jeffries Date: Tue, 3 Feb 2015 15:42:23 +0000 (-0800) Subject: Cleanup: migrate ESI objects to CBDATA_CLASS API X-Git-Tag: merge-candidate-3-v1~294 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c41d298901ae92cd5b78cce9568edfd1c091be8;p=thirdparty%2Fsquid.git Cleanup: migrate ESI objects to CBDATA_CLASS API Replace several objects use of CBDATA_TYPE to CBDATA_CLASS. Change esiRemove from CBDATA to MEMPROXY_CLASS. Remove dead code from earlier CBDATA updates. --- diff --git a/src/esi/Attempt.h b/src/esi/Attempt.h index 391cb0605b..47b0a89d42 100644 --- a/src/esi/Attempt.h +++ b/src/esi/Attempt.h @@ -14,11 +14,7 @@ #include "esi/Element.h" #include "esi/Sequence.h" -/* esiAttempt */ - struct esiAttempt : public esiSequence { - // void *operator new (size_t byteCount); - // void operator delete (void *address); esiAttempt(esiTreeParentPtr aParent) : esiSequence (aParent) {} }; diff --git a/src/esi/Esi.cc b/src/esi/Esi.cc index 99c16a4b97..dd6e3bccc3 100644 --- a/src/esi/Esi.cc +++ b/src/esi/Esi.cc @@ -29,6 +29,7 @@ #include "esi/Expression.h" #include "esi/Segment.h" #include "esi/VarState.h" +#include "fatal.h" #include "HttpHdrSc.h" #include "HttpHdrScTarget.h" #include "HttpReply.h" @@ -104,23 +105,19 @@ public: class esiRemove : public ESIElement { + MEMPROXY_CLASS(esiRemove); public: - void *operator new (size_t byteCount); - void operator delete (void *address); - - esiRemove(); - void render(ESISegment::Pointer); - bool addElement (ESIElement::Pointer); - Pointer makeCacheable() const; - Pointer makeUsable(esiTreeParentPtr, ESIVarState &) const; - void finish(); + esiRemove() : ESIElement() {} + virtual ~esiRemove() {} + + virtual void render(ESISegment::Pointer); + virtual bool addElement (ESIElement::Pointer); + virtual Pointer makeCacheable() const; + virtual Pointer makeUsable(esiTreeParentPtr, ESIVarState &) const; + virtual void finish() {} }; -CBDATA_TYPE (esiRemove); -static FREE esiRemoveFree; -static ESIElement * esiRemoveNew(void); - class esiTry : public ESIElement { MEMPROXY_CLASS(esiTry); @@ -213,8 +210,6 @@ private: }; struct esiOtherwise : public esiSequence { - // void *operator new (size_t byteCount); - // void operator delete (void *address); esiOtherwise(esiTreeParentPtr aParent) : esiSequence (aParent) {} }; @@ -1021,7 +1016,7 @@ ESIContext::start(const char *el, const char **attr, size_t attrCount) case ESIElement::ESI_ELEMENT_REMOVE: /* Put on the stack to allow skipping of 'invalid' markup */ - element = esiRemoveNew (); + element = new esiRemove(); break; case ESIElement::ESI_ELEMENT_TRY: @@ -1584,42 +1579,6 @@ esiLiteral::makeUsable(esiTreeParentPtr , ESIVarState &newVarState) const } /* esiRemove */ -void -esiRemoveFree (void *data) -{ - esiRemove *thisNode = (esiRemove *)data; - debugs(86, 5, "esiRemoveFree " << thisNode); -} - -void * -esiRemove::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiRemove)); - void *rv; - CBDATA_INIT_TYPE_FREECB(esiRemove, esiRemoveFree); - rv = (void *)cbdataAlloc (esiRemove); - return rv; -} - -void -esiRemove::operator delete (void *address) -{ - cbdataFree (address); -} - -ESIElement * -esiRemoveNew () -{ - return new esiRemove; -} - -esiRemove::esiRemove() -{} - -void -esiRemove::finish() -{} - void esiRemove::render(ESISegment::Pointer output) { @@ -1916,63 +1875,6 @@ esiTry::finish() except = NULL; } -/* esiAttempt */ -#if 0 -void * -esiAttempt::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiAttempt)); - -} - -void -esiAttempt::operator delete (void *address) -{ - cbdataFree (address); -} - -#endif - -/* esiExcept */ -#if 0 -void * -esiExcept::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiExcept)); - void *rv; - CBDATA_INIT_TYPE_FREECB(esiExcept, esiSequence::Free); - rv = (void *)cbdataAlloc (esiExcept); - return rv; -} - -void -esiExcept::operator delete (void *address) -{ - cbdataFree (address); -} - -#endif - -/* ESIVar */ -#if 0 -void * -esiVar::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiVar)); - void *rv; - CBDATA_INIT_TYPE_FREECB(esiVar, esiSequence::Free); - rv = (void *)cbdataAlloc (esiVar); - return rv; -} - -void -esiVar::operator delete (void *address) -{ - cbdataFree (address); -} - -#endif - /* esiChoose */ esiChoose::~esiChoose() { @@ -2369,26 +2271,6 @@ esiWhen::makeUsable(esiTreeParentPtr newParent, ESIVarState &newVarState) const return result; } -/* esiOtherwise */ -#if 0 -void * -esiOtherwise::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (esiOtherwise)); - void *rv; - CBDATA_INIT_TYPE_FREECB(esiOtherwise, esiSequence::Free); - rv = (void *)cbdataAlloc (esiOtherwise); - return rv; -} - -void -esiOtherwise::operator delete (void *address) -{ - cbdataFree (address); -} - -#endif - /* TODO: implement surrogate targeting and control processing */ int esiEnableProcessing (HttpReply *rep) diff --git a/src/esi/Except.h b/src/esi/Except.h index e275b855a9..030ce75e12 100644 --- a/src/esi/Except.h +++ b/src/esi/Except.h @@ -20,8 +20,6 @@ class esiExcept : public esiSequence { public: - // void *operator new (size_t byteCount); - // void operator delete (void *address); esiExcept(esiTreeParentPtr aParent) : esiSequence (aParent) {} }; diff --git a/src/esi/Include.cc b/src/esi/Include.cc index 6d702e3655..9dec46541d 100644 --- a/src/esi/Include.cc +++ b/src/esi/Include.cc @@ -10,15 +10,13 @@ #include "squid.h" -/* MS Visual Studio Projects are monolithic, so we need the following - * #if to exclude the ESI code from compile process when not needed. - */ -#if (USE_SQUID_ESI == 1) +#if USE_SQUID_ESI #include "client_side.h" #include "client_side_request.h" #include "esi/Include.h" #include "esi/VarState.h" +#include "fatal.h" #include "HttpReply.h" #include "log/access_log.h" @@ -559,5 +557,5 @@ ESIInclude::subRequestDone (ESIStreamContext::Pointer stream, bool success) } } -#endif /* USE_SQUID_ESI == 1 */ +#endif /* USE_SQUID_ESI */ diff --git a/src/esi/Segment.cc b/src/esi/Segment.cc index 22e438fe60..eaa2b74bf4 100644 --- a/src/esi/Segment.cc +++ b/src/esi/Segment.cc @@ -13,9 +13,8 @@ #include "esi/Segment.h" #include "SquidString.h" -CBDATA_TYPE(ESISegment); +CBDATA_CLASS_INIT(ESISegment); -/* ESISegment */ void ESISegmentFreeList (ESISegment::Pointer &head) { @@ -126,22 +125,6 @@ ESISegment::ListAppend (ESISegment::Pointer &head, char const *s, size_t len) head->tail()->listAppend (s, len); } -void * -ESISegment::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (ESISegment)); - void *rv; - CBDATA_INIT_TYPE(ESISegment); - rv = (void *)cbdataAlloc (ESISegment); - return rv; -} - -void -ESISegment::operator delete (void *address) -{ - cbdataFree (address); -} - /* XXX: if needed, make this iterative */ ESISegment::Pointer ESISegment::cloneList () const @@ -188,9 +171,6 @@ ESISegment::tail() return result.getRaw(); } -ESISegment::ESISegment() : len(0), next(NULL) -{} - ESISegment::ESISegment(ESISegment const &old) : len (0), next(NULL) { append (old.buf, old.len); diff --git a/src/esi/Segment.h b/src/esi/Segment.h index 007406dc29..99c97ab435 100644 --- a/src/esi/Segment.h +++ b/src/esi/Segment.h @@ -20,16 +20,17 @@ class ESISegment : public RefCountable { + CBDATA_CLASS(ESISegment); public: typedef RefCount Pointer; static void ListAppend (Pointer &, char const *, size_t); static void ListTransfer (Pointer &from, Pointer &to); - void *operator new (size_t byteCount); - void operator delete (void *address); - ESISegment(); + ESISegment() : len(0), next(NULL) {*buf = 0;} ESISegment(ESISegment const &); + ~ESISegment() {} + ESISegment::Pointer cloneList() const; char *listToChar() const; void listAppend (char const *s, size_t length); diff --git a/src/esi/Var.h b/src/esi/Var.h index e649c3e674..8abe88e8e4 100644 --- a/src/esi/Var.h +++ b/src/esi/Var.h @@ -20,8 +20,6 @@ class ESIVar:public esiSequence { public: - // void *operator new (size_t byteCount); - // void operator delete (void *address); ESIVar(esiTreeParentPtr aParent) : esiSequence (aParent) { flags.dovars = 1; } diff --git a/src/esi/VarState.cc b/src/esi/VarState.cc index 76750c7cc7..a457b4f61e 100644 --- a/src/esi/VarState.cc +++ b/src/esi/VarState.cc @@ -13,9 +13,6 @@ #include "fatal.h" #include "HttpReply.h" -CBDATA_TYPE (ESIVarState); -FREE ESIVarStateFree; - char const *ESIVariableUserAgent::esiUserOs[]= { "WIN", "MAC", @@ -28,6 +25,8 @@ char const * esiBrowsers[]= {"MSIE", "OTHER" }; +CBDATA_CLASS_INIT(ESIVarState); + void ESIVarState::Variable::eval (ESIVarState &state, char const *subref, char const *found_default) const { @@ -131,17 +130,12 @@ ESIVarState::extractChar () return rv; } -/* ESIVarState */ -void -esiVarStateFree (void *data) -{ - ESIVarState *thisNode = (ESIVarState*)data; - thisNode->freeResources(); -} - ESIVarState::~ESIVarState() { - freeResources(); + // freeResources + input = NULL; + ESISegmentFreeList(output); + hdr.clean(); while (!variablesForCleanup.empty()) { delete variablesForCleanup.back(); @@ -151,30 +145,6 @@ ESIVarState::~ESIVarState() delete defaultVariable; } -void -ESIVarState::freeResources() -{ - input = NULL; - ESISegmentFreeList (output); - hdr.clean(); -} - -void * -ESIVarState::operator new(size_t byteCount) -{ - assert (byteCount == sizeof (ESIVarState)); - void *rv; - CBDATA_INIT_TYPE_FREECB(ESIVarState, esiVarStateFree); - rv = (void *)cbdataAlloc (ESIVarState); - return rv; -} - -void -ESIVarState::operator delete (void *address) -{ - cbdataFree (address); -} - char * ESIVariableUserAgent::getProductVersion (char const *s) { diff --git a/src/esi/VarState.h b/src/esi/VarState.h index 314aa231f5..1ad5b9d73e 100644 --- a/src/esi/VarState.h +++ b/src/esi/VarState.h @@ -33,8 +33,12 @@ struct _query_elem {char *var, *val;}; class ESIVarState { + CBDATA_CLASS(ESIVarState); public: + ESIVarState(HttpHeader const *hdr, char const *uri); + ~ESIVarState(); + ESISegment::Pointer extractList(); char *extractChar(); void feedData (const char *buf, size_t len); @@ -44,12 +48,6 @@ public: void addVariable (char const *, size_t, Variable *); void removeVariable (String const &); - void *operator new (size_t byteCount); - void operator delete (void *address); - void freeResources(); - ESIVarState (HttpHeader const *hdr, char const *uri); - ~ESIVarState(); - /* For Variables */ void cookieUsed(); void hostUsed();