From c31bb5195e648d73a9ea0cba281468ba19efa18d Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Thu, 24 Oct 2013 11:27:28 -0600 Subject: [PATCH] Convert WhoisStateData to CBDATA_CLASS Removes one more set of cbdataAlloc/cbdataFree. Also, updates its HttpRequest reference to a Pointer --- src/whois.cc | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/whois.cc b/src/whois.cc index da1a4dbaf5..2d98a33438 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -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" @@ -52,31 +51,27 @@ 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 ¶ms) WhoisState *p = (WhoisState *)params.data; debugs(75, 3, "whoisClose: FD " << params.fd); p->entry->unlock(); - cbdataFree(p); + delete p; } -- 2.47.3