From: Mukund Sivaraman Date: Mon, 6 May 2013 06:07:14 +0000 (+0530) Subject: [2850] Constify getNamedAddress() X-Git-Tag: bind10-1.2.0beta1-release~467^2~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5082c255bbeb8c83f9ab08d4e28429cc271b2fec;p=thirdparty%2Fkea.git [2850] Constify getNamedAddress() --- diff --git a/src/lib/util/memory_segment.h b/src/lib/util/memory_segment.h index e83c3e0c26..f94372a7cd 100644 --- a/src/lib/util/memory_segment.h +++ b/src/lib/util/memory_segment.h @@ -254,7 +254,7 @@ public: /// \return An std::pair containing a bool (set to true if the name /// was found, or false otherwise) and the address associated with /// the name (which is undefined if the name was not found). - NamedAddressResult getNamedAddress(const char* name) { + NamedAddressResult getNamedAddress(const char* name) const { // This public method implements common validation. The actual // work specific to the derived segment is delegated to the // corresponding protected method. @@ -296,7 +296,7 @@ protected: virtual bool setNamedAddressImpl(const char* name, void* addr) = 0; /// \brief Implementation of getNamedAddress beyond common validation. - virtual NamedAddressResult getNamedAddressImpl(const char* name) = 0; + virtual NamedAddressResult getNamedAddressImpl(const char* name) const = 0; /// \brief Implementation of clearNamedAddress beyond common validation. virtual bool clearNamedAddressImpl(const char* name) = 0; diff --git a/src/lib/util/memory_segment_local.cc b/src/lib/util/memory_segment_local.cc index e68db2792b..b81fe5e915 100644 --- a/src/lib/util/memory_segment_local.cc +++ b/src/lib/util/memory_segment_local.cc @@ -52,8 +52,9 @@ MemorySegmentLocal::allMemoryDeallocated() const { } MemorySegment::NamedAddressResult -MemorySegmentLocal::getNamedAddressImpl(const char* name) { - std::map::iterator found = named_addrs_.find(name); +MemorySegmentLocal::getNamedAddressImpl(const char* name) const { + std::map::const_iterator found = + named_addrs_.find(name); if (found != named_addrs_.end()) { return (NamedAddressResult(true, found->second)); } diff --git a/src/lib/util/memory_segment_local.h b/src/lib/util/memory_segment_local.h index 90d4907c05..de7249e448 100644 --- a/src/lib/util/memory_segment_local.h +++ b/src/lib/util/memory_segment_local.h @@ -70,7 +70,7 @@ public: /// /// There's a small chance this method could throw std::bad_alloc. /// It should be considered a fatal error. - virtual NamedAddressResult getNamedAddressImpl(const char* name); + virtual NamedAddressResult getNamedAddressImpl(const char* name) const; /// \brief Local segment version of setNamedAddress. /// diff --git a/src/lib/util/memory_segment_mapped.cc b/src/lib/util/memory_segment_mapped.cc index ca9c9c6cee..f53306b353 100644 --- a/src/lib/util/memory_segment_mapped.cc +++ b/src/lib/util/memory_segment_mapped.cc @@ -280,7 +280,7 @@ MemorySegmentMapped::allMemoryDeallocated() const { } MemorySegment::NamedAddressResult -MemorySegmentMapped::getNamedAddressImpl(const char* name) { +MemorySegmentMapped::getNamedAddressImpl(const char* name) const { offset_ptr* storage = impl_->base_sgmt_->find >(name).first; if (storage) { diff --git a/src/lib/util/memory_segment_mapped.h b/src/lib/util/memory_segment_mapped.h index 679821069d..492cf866f1 100644 --- a/src/lib/util/memory_segment_mapped.h +++ b/src/lib/util/memory_segment_mapped.h @@ -195,7 +195,7 @@ public: /// \brief Mapped segment version of getNamedAddress. /// /// This version never throws. - virtual NamedAddressResult getNamedAddressImpl(const char* name); + virtual NamedAddressResult getNamedAddressImpl(const char* name) const; /// \brief Mapped segment version of clearNamedAddress. ///