From: robertc <> Date: Mon, 23 Jun 2003 18:03:07 +0000 (+0000) Subject: Summary: CBData reference callback pointers in comm_read and related.. X-Git-Tag: SQUID_3_0_PRE1~91 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=42d9b8e57006eac2c23b1a1f5f2bda9d3e273d91;p=thirdparty%2Fsquid.git Summary: CBData reference callback pointers in comm_read and related.. Keywords: We were not cbdata referencing user supplied pointers. This allows user supplied data to be freed before we call back. Still TODO: check for cbdataReferenceValid upon callback. --- diff --git a/src/CommRead.h b/src/CommRead.h index 18b3e4b5a9..c187afaf1b 100644 --- a/src/CommRead.h +++ b/src/CommRead.h @@ -1,6 +1,6 @@ /* - * $Id: CommRead.h,v 1.2 2003/03/08 09:35:15 robertc Exp $ + * $Id: CommRead.h,v 1.3 2003/06/23 12:03:07 robertc Exp $ * * DEBUG: section 5 Comms * AUTHOR: Robert Collins @@ -51,9 +51,40 @@ class CallBack public: CallBack() : handler(NULL), data(NULL){} - CallBack(C *aHandler, void *someData) : handler(aHandler), data(someData){} + CallBack(C *aHandler, void *someData) : handler(aHandler), data (NULL) + { + if (someData) + data = cbdataReference(someData); + } - bool operator == (CallBack const &rhs) { return handler==rhs.handler && data==rhs.data;} + CallBack(CallBack const &old) : handler(old.handler) + { + if (old.data) + data = cbdataReference (old.data); + else + data = NULL; + } + + ~CallBack() + { + if (data) + cbdataReferenceDone(data); + } + + CallBack &operator = (CallBack const & rhs) + { + handler = rhs.handler; + + if (rhs.data) + data = cbdataReference (rhs.data); + else + data = NULL; + + return *this; + } + + +bool operator == (CallBack const &rhs) { return handler==rhs.handler && data==rhs.data;} #if 0 // twould be nice - RBC 20030307