From: Francesco Chemolli Date: Wed, 2 Sep 2015 16:44:17 +0000 (+0200) Subject: const-ified where possible, added cbdata checks. X-Git-Tag: SQUID_4_0_1~21^2~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26ba1d872e7d89b2b200ff48118235fb5620b6e7;p=thirdparty%2Fsquid.git const-ified where possible, added cbdata checks. --- diff --git a/src/auth/UserNameCache.cc b/src/auth/UserNameCache.cc index 32e4681083..1eee7e1dc4 100644 --- a/src/auth/UserNameCache.cc +++ b/src/auth/UserNameCache.cc @@ -25,7 +25,7 @@ UserNameCache::UserNameCache(const char *name) : } Auth::User::Pointer -UserNameCache::lookup(const SBuf &userKey) +UserNameCache::lookup(const SBuf &userKey) const { auto p = store_.find(userKey); if (p == store_.end()) @@ -36,6 +36,8 @@ UserNameCache::lookup(const SBuf &userKey) void UserNameCache::Cleanup(void *data) { + if (!cbdataReferenceValid(data)) + return; // data is this in disguise UserNameCache *self = static_cast(data); // cache entries with expiretime <= expirationTime are to be evicted @@ -56,7 +58,7 @@ UserNameCache::insert(Auth::User::Pointer anAuth_user) // generates the list of cached usernames in a format that is convenient // to merge with equivalent lists obtained from other UserNameCaches. std::vector -UserNameCache::sortedUsersList() +UserNameCache::sortedUsersList() const { std::vector rv(size(), nullptr); std::transform(store_.begin(), store_.end(), rv.begin(), diff --git a/src/auth/UserNameCache.h b/src/auth/UserNameCache.h index 2192760651..5409abcfbd 100644 --- a/src/auth/UserNameCache.h +++ b/src/auth/UserNameCache.h @@ -40,7 +40,7 @@ public: UserNameCache& operator=(const UserNameCache&) = delete; /// obtain pointer to user if present, or Pointer(nullptr) if not - Auth::User::Pointer lookup(const SBuf &userKey); + Auth::User::Pointer lookup(const SBuf &userKey) const; /// add an user to the cache void insert(Auth::User::Pointer anAuth_user); @@ -49,7 +49,7 @@ public: void reset() { store_.clear(); } /// extract number of cached usernames - size_t size() { return store_.size(); } + size_t size() const { return store_.size(); } /** periodic cleanup function, removes timed-out entries * @@ -60,10 +60,11 @@ public: /** obtain sorted list of usernames * */ - std::vector sortedUsersList(); + std::vector sortedUsersList() const; /// RegisteredRunner API virtual void endingShutdown() override; + private: StoreType store_;