]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert WhoisStateData to CBDATA_CLASS
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 24 Oct 2013 17:27:28 +0000 (11:27 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 24 Oct 2013 17:27:28 +0000 (11:27 -0600)
Removes one more set of cbdataAlloc/cbdataFree.
Also, updates its HttpRequest reference to a Pointer

src/whois.cc

index da1a4dbaf56fc7e0322d1921754ef2de301d8753..2d98a334381112ab21d88c6a38d692db91fedd64 100644 (file)
@@ -38,7 +38,6 @@
 #include "FwdState.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
-#include "HttpRequest.h"
 #include "SquidConfig.h"
 #include "StatCounters.h"
 #include "Store.h"
 
 class WhoisState
 {
-
 public:
-    ~WhoisState();
     void readReply(const Comm::ConnectionPointer &, char *aBuffer, size_t aBufferLength, comm_err_t flag, int xerrno);
     void setReplyToOK(StoreEntry *sentry);
     StoreEntry *entry;
-    HttpRequest *request;
+    HttpRequest::Pointer request;
     FwdState::Pointer fwd;
     char buf[BUFSIZ+1];                /* readReply adds terminating NULL */
     bool dataWritten;
+
+private:
+    CBDATA_CLASS2(WhoisState);
 };
 
+CBDATA_CLASS_INIT(WhoisState);
+
 static CLCB whoisClose;
 static CTCB whoisTimeout;
 static IOCB whoisReadReply;
 
 /* PUBLIC */
 
-CBDATA_TYPE(WhoisState);
-
-WhoisState::~WhoisState()
-{
-    fwd = NULL;        // refcounted
-}
-
 static void
 whoisWriteComplete(const Comm::ConnectionPointer &, char *buf, size_t size, comm_err_t flag, int xerrno, void *data)
 {
@@ -86,11 +81,9 @@ whoisWriteComplete(const Comm::ConnectionPointer &, char *buf, size_t size, comm
 void
 whoisStart(FwdState * fwd)
 {
-    WhoisState *p;
     char *buf;
     size_t l;
-    CBDATA_INIT_TYPE(WhoisState);
-    p = cbdataAlloc(WhoisState);
+    WhoisState *p = new WhoisState;
     p->request = fwd->request;
     p->entry = fwd->entry;
     p->fwd = fwd;
@@ -206,5 +199,5 @@ whoisClose(const CommCloseCbParams &params)
     WhoisState *p = (WhoisState *)params.data;
     debugs(75, 3, "whoisClose: FD " << params.fd);
     p->entry->unlock();
-    cbdataFree(p);
+    delete p;
 }