BIND 10 trac2185, updated. 9ac39be69c035539d8bca28d3a5e6dd5d0d2ef19 [2185] Add and use a RdataPimplHolder instead of auto_ptr
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Feb 7 13:03:28 UTC 2014
The branch, trac2185 has been updated
via 9ac39be69c035539d8bca28d3a5e6dd5d0d2ef19 (commit)
from d88bd0463689b5d44ff6617ce080bb75f256bf96 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 9ac39be69c035539d8bca28d3a5e6dd5d0d2ef19
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Feb 7 18:30:50 2014 +0530
[2185] Add and use a RdataPimplHolder instead of auto_ptr
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/rdata/generic/tlsa_52.cc | 9 ++--
.../nsec3hash_python.h => rdata_pimpl_holder.h} | 57 ++++++++++++--------
2 files changed, 39 insertions(+), 27 deletions(-)
copy src/lib/dns/{python/nsec3hash_python.h => rdata_pimpl_holder.h} (55%)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/rdata/generic/tlsa_52.cc b/src/lib/dns/rdata/generic/tlsa_52.cc
index fdf3bc3..a896e8d 100644
--- a/src/lib/dns/rdata/generic/tlsa_52.cc
+++ b/src/lib/dns/rdata/generic/tlsa_52.cc
@@ -24,6 +24,7 @@
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
+#include <dns/rdata_pimpl_holder.h>
using namespace std;
using boost::lexical_cast;
@@ -126,10 +127,10 @@ TLSA::constructFromLexer(MasterLexer& lexer) {
TLSA::TLSA(const string& tlsa_str) :
impl_(NULL)
{
- // We use auto_ptr here because if there is an exception in this
- // constructor, the destructor is not called and there could be a
- // leak of the TLSAImpl that constructFromLexer() returns.
- std::auto_ptr<TLSAImpl> impl_ptr(NULL);
+ // We use a smart pointer here because if there is an exception in
+ // this constructor, the destructor is not called and there could be
+ // a leak of the TLSAImpl that constructFromLexer() returns.
+ RdataPimplHolder<TLSAImpl> impl_ptr;
try {
std::istringstream ss(tlsa_str);
diff --git a/src/lib/dns/rdata_pimpl_holder.h b/src/lib/dns/rdata_pimpl_holder.h
new file mode 100644
index 0000000..4564405
--- /dev/null
+++ b/src/lib/dns/rdata_pimpl_holder.h
@@ -0,0 +1,58 @@
+// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef DNS_RDATA_PIMPL_HOLDER_H
+#define DNS_RDATA_PIMPL_HOLDER_H 1
+
+#include <boost/noncopyable.hpp>
+
+namespace isc {
+namespace dns {
+namespace rdata {
+
+template <typename T>
+class RdataPimplHolder : boost::noncopyable {
+public:
+ RdataPimplHolder(T* obj = NULL) :
+ obj_(obj)
+ {}
+
+ ~RdataPimplHolder() {
+ delete obj_;
+ }
+
+ void reset(T* obj = NULL) {
+ delete obj_;
+ obj_ = obj;
+ }
+
+ T* get() {
+ return (obj_);
+ }
+
+ T* release() {
+ T* obj = obj_;
+ obj_ = NULL;
+ return (obj);
+ }
+
+private:
+ T* obj_;
+};
+
+} // namespace rdata
+} // namespace dns
+} // namespace isc
+
+#endif // DNS_RDATA_PIMPL_HOLDER_H
More information about the bind10-changes
mailing list