From 7e7aac708484428fe03a1f01a9a7245d680b2c41 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 30 Oct 2017 21:23:57 +0000 Subject: Use std::shared_ptr and variadic calls to make_shared in shared components --- netfs/lib/entCache.cpp | 12 ++++++------ netfs/lib/entCache.h | 10 ++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/netfs/lib/entCache.cpp b/netfs/lib/entCache.cpp index 6699a4b..fbdba3e 100644 --- a/netfs/lib/entCache.cpp +++ b/netfs/lib/entCache.cpp @@ -84,7 +84,7 @@ EntCache::fillCache() const char buf[BUFLEN]; struct passwd pwbuf, * pwp; while (getpwent_r(&pwbuf, buf, BUFLEN, &pwp) == 0) { - idcache.insert(new User(pwp->pw_uid, pwp->pw_name, pwp->pw_gid)); + idcache.insert(std::make_shared(pwp->pw_uid, pwp->pw_name, pwp->pw_gid)); } endpwent(); time(&fillTime); @@ -107,7 +107,7 @@ EntCache::fillCache() const struct group grpbuf, * grp; EntCache instance; while (getgrent_r(&grpbuf, buf, BUFLEN, &grp) == 0) { - auto g = new Group(grp->gr_gid, grp->gr_name); + auto g = std::make_shared(grp->gr_gid, grp->gr_name); for (auto member = grp->gr_mem; *member; member++) { try { g->members.insert(instance.getEntry((const name_t &)*member)->id); @@ -129,15 +129,15 @@ DLL_PUBLIC Group::hasMember(uid_t u) const template DLL_PUBLIC EntCache::EntCache(); template DLL_PUBLIC EntCache::~EntCache(); -template IceUtil::Handle DLL_PUBLIC EntCache::getEntry(const std::string &) const; -template IceUtil::Handle DLL_PUBLIC EntCache::getEntry(const uid_t &) const; +template std::shared_ptr DLL_PUBLIC EntCache::getEntry(const std::string &) const; +template std::shared_ptr DLL_PUBLIC EntCache::getEntry(const uid_t &) const; template DLL_PUBLIC void EntCache::getName(const gid_t &, std::string *) const; template DLL_PUBLIC void EntCache::getID(const std::string &, gid_t *) const; template DLL_PUBLIC EntCache::EntCache(); template DLL_PUBLIC EntCache::~EntCache(); -template IceUtil::Handle DLL_PUBLIC EntCache::getEntry(const std::string &) const; -template IceUtil::Handle DLL_PUBLIC EntCache::getEntry(const gid_t &) const; +template std::shared_ptr DLL_PUBLIC EntCache::getEntry(const std::string &) const; +template std::shared_ptr DLL_PUBLIC EntCache::getEntry(const gid_t &) const; template DLL_PUBLIC void EntCache::getName(const gid_t &, std::string *) const; template DLL_PUBLIC void EntCache::getID(const std::string &, gid_t *) const; diff --git a/netfs/lib/entCache.h b/netfs/lib/entCache.h index 7e82171..1ded6ee 100644 --- a/netfs/lib/entCache.h +++ b/netfs/lib/entCache.h @@ -3,15 +3,13 @@ #include #include -#include -#include #include #include #include #include #include -class User : public IceUtil::Shared { +class User { public: User(uid_t, const std::string &, gid_t); uid_t id; @@ -19,7 +17,7 @@ class User : public IceUtil::Shared { gid_t group; }; -class Group : public IceUtil::Shared { +class Group { public: Group(gid_t, const std::string &); @@ -35,7 +33,7 @@ class EntCache : public EntryResolver { public: typedef decltype(entry_t::id) id_t; typedef decltype(entry_t::name) name_t; - typedef IceUtil::Handle entry_ptr; + typedef std::shared_ptr entry_ptr; EntCache(); virtual ~EntCache(); @@ -50,7 +48,7 @@ class EntCache : public EntryResolver { template entry_ptr getEntryNoFill(const key_t &) const; - typedef boost::multi_index::multi_index_container, + typedef boost::multi_index::multi_index_container, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag, BOOST_MULTI_INDEX_MEMBER(entry_t, const id_t, id)>, -- cgit v1.2.3