summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJINMEI Tatuya <jinmei@isc.org>2010-03-05 01:02:08 +0100
committerJINMEI Tatuya <jinmei@isc.org>2010-03-05 01:02:08 +0100
commit3e248e341bc0076fae286ae4835b8a2368f2efb4 (patch)
treebfd4a55e91fdca6f8e3ac75d96593c0313d8d78b /src/lib
parentoverall cleanup: (diff)
downloadkea-3e248e341bc0076fae286ae4835b8a2368f2efb4.tar.xz
kea-3e248e341bc0076fae286ae4835b8a2368f2efb4.zip
- made AuthSrv construction exception-safe
- fixed memory leak for Datasrc* stored in the MetaDataSrc vector. there are several possible ways to do this, but I chose to using boost::shared_ptr. expect for portability issues this seems to be the cleanest solution, and, regarding portability, we already heavily rely on boost anyway, so we should revisit the whole design if/when we seriously consider binary portability. git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1118 e5f2f494-b856-4b98-b285-d166d9295462
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/auth/cpp/data_source.cc13
-rw-r--r--src/lib/auth/cpp/data_source.h10
2 files changed, 15 insertions, 8 deletions
diff --git a/src/lib/auth/cpp/data_source.cc b/src/lib/auth/cpp/data_source.cc
index f09e3664ac..aa59dab930 100644
--- a/src/lib/auth/cpp/data_source.cc
+++ b/src/lib/auth/cpp/data_source.cc
@@ -645,24 +645,25 @@ DataSrc::findReferral(const Query& q, const Name& qname, const RRClass& qclass,
}
void
-MetaDataSrc::addDataSrc(DataSrc* ds)
+MetaDataSrc::addDataSrc(ConstDataSrcPtr data_src)
{
- if (getClass() != RRClass::ANY() && ds->getClass() != getClass()) {
+ if (getClass() != RRClass::ANY() && data_src->getClass() != getClass()) {
dns_throw(Unexpected, "class mismatch");
}
- data_sources.push_back(ds);
+ data_sources.push_back(data_src);
}
void
MetaDataSrc::findClosestEnclosure(NameMatch& match) const
{
- BOOST_FOREACH (DataSrc* ds, data_sources) {
- if (getClass() != RRClass::ANY() && ds->getClass() != getClass()) {
+ BOOST_FOREACH (ConstDataSrcPtr data_src, data_sources) {
+ if (getClass() != RRClass::ANY() &&
+ data_src->getClass() != getClass()) {
continue;
}
- ds->findClosestEnclosure(match);
+ data_src->findClosestEnclosure(match);
}
}
diff --git a/src/lib/auth/cpp/data_source.h b/src/lib/auth/cpp/data_source.h
index 7722856c26..ec9cd7284b 100644
--- a/src/lib/auth/cpp/data_source.h
+++ b/src/lib/auth/cpp/data_source.h
@@ -19,6 +19,8 @@
#include <vector>
+#include <boost/shared_ptr.hpp>
+
#include <dns/name.h>
#include <dns/rrclass.h>
@@ -36,6 +38,10 @@ namespace auth {
class NameMatch;
class Query;
+class DataSrc;
+typedef boost::shared_ptr<DataSrc> DataSrcPtr;
+typedef boost::shared_ptr<const DataSrc> ConstDataSrcPtr;
+
class AbstractDataSrc {
///
/// \name Constructors, Assignment Operator and Destructor.
@@ -220,7 +226,7 @@ public:
virtual ~MetaDataSrc() {}
//@}
- void addDataSrc(DataSrc* ds);
+ void addDataSrc(ConstDataSrcPtr data_src);
void findClosestEnclosure(NameMatch& match) const;
// Actual queries for data should not be sent to a MetaDataSrc object,
@@ -273,7 +279,7 @@ public:
}
private:
- std::vector<DataSrc*> data_sources;
+ std::vector<ConstDataSrcPtr> data_sources;
};
class NameMatch {