From: Mukund Sivaraman Date: Wed, 18 Sep 2013 12:03:03 +0000 (+0530) Subject: [3112] Assign the TTL objects using a helper function X-Git-Tag: bind10-1.2.0beta1-release~205^2^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab67242d4cf7ae3bbdb7d0a57f55b44350cfc2fc;p=thirdparty%2Fkea.git [3112] Assign the TTL objects using a helper function --- diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc index 6a34c25bc7..6b6e091489 100644 --- a/src/lib/dns/master_loader.cc +++ b/src/lib/dns/master_loader.cc @@ -275,11 +275,7 @@ private: // care about where it comes from). see LimitTTL() for parameter // post_parsing. void setDefaultTTL(const RRTTL& ttl, bool post_parsing) { - if (!default_ttl_) { - default_ttl_.reset(new RRTTL(ttl)); - } else { - *default_ttl_ = ttl; - } + assignTTL(default_ttl_, ttl); limitTTL(*default_ttl_, post_parsing); } @@ -324,11 +320,7 @@ private: dynamic_cast(*rdata). getMinimum(); setDefaultTTL(RRTTL(ttl_val), true); - if (!current_ttl_) { - current_ttl_.reset(new RRTTL(*default_ttl_)); - } else { - *current_ttl_ = *default_ttl_; - } + assignTTL(current_ttl_, *default_ttl_); } else { // On catching the exception we'll try to reach EOL again, // so we need to unget it now. @@ -337,11 +329,7 @@ private: "no TTL specified; load rejected"); } } else if (!explicit_ttl && default_ttl_) { - if (!current_ttl_) { - current_ttl_.reset(new RRTTL(*default_ttl_)); - } else { - *current_ttl_ = *default_ttl_; - } + assignTTL(current_ttl_, *default_ttl_); } else if (!explicit_ttl && warn_rfc1035_ttl_) { // Omitted (class and) TTL values are default to the last // explicitly stated values (RFC 1035, Sec. 5.1). @@ -398,6 +386,17 @@ private: } } + /// \brief Assign the right RRTTL's value to the left RRTTL. If one + /// doesn't exist in the scoped_ptr, make a new RRTTL copy of the + /// right argument. + static void assignTTL(boost::scoped_ptr& left, const RRTTL& right) { + if (!left) { + left.reset(new RRTTL(right)); + } else { + *left = right; + } + } + private: MasterLexer lexer_; const Name zone_origin_;