summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-10-30 21:23:57 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2017-12-16 20:51:55 +0000
commit7e7aac708484428fe03a1f01a9a7245d680b2c41 (patch)
treef6a61c0ce1009b4cf6e4ea85dfb305965b7dc5ae
parentUse std::shared_ptr and variadic calls to make_shared in fuse components (diff)
downloadnetfs-7e7aac708484428fe03a1f01a9a7245d680b2c41.tar.bz2
netfs-7e7aac708484428fe03a1f01a9a7245d680b2c41.tar.xz
netfs-7e7aac708484428fe03a1f01a9a7245d680b2c41.zip
Use std::shared_ptr and variadic calls to make_shared in shared components
-rw-r--r--netfs/lib/entCache.cpp12
-rw-r--r--netfs/lib/entCache.h10
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<User>::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<User>(pwp->pw_uid, pwp->pw_name, pwp->pw_gid));
}
endpwent();
time(&fillTime);
@@ -107,7 +107,7 @@ EntCache<Group>::fillCache() const
struct group grpbuf, * grp;
EntCache<User> instance;
while (getgrent_r(&grpbuf, buf, BUFLEN, &grp) == 0) {
- auto g = new Group(grp->gr_gid, grp->gr_name);
+ auto g = std::make_shared<Group>(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<User>::EntCache();
template DLL_PUBLIC EntCache<User>::~EntCache();
-template IceUtil::Handle<User> DLL_PUBLIC EntCache<User>::getEntry<std::string>(const std::string &) const;
-template IceUtil::Handle<User> DLL_PUBLIC EntCache<User>::getEntry<uid_t>(const uid_t &) const;
+template std::shared_ptr<User> DLL_PUBLIC EntCache<User>::getEntry<std::string>(const std::string &) const;
+template std::shared_ptr<User> DLL_PUBLIC EntCache<User>::getEntry<uid_t>(const uid_t &) const;
template DLL_PUBLIC void EntCache<User>::getName(const gid_t &, std::string *) const;
template DLL_PUBLIC void EntCache<User>::getID(const std::string &, gid_t *) const;
template DLL_PUBLIC EntCache<Group>::EntCache();
template DLL_PUBLIC EntCache<Group>::~EntCache();
-template IceUtil::Handle<Group> DLL_PUBLIC EntCache<Group>::getEntry<std::string>(const std::string &) const;
-template IceUtil::Handle<Group> DLL_PUBLIC EntCache<Group>::getEntry<gid_t>(const gid_t &) const;
+template std::shared_ptr<Group> DLL_PUBLIC EntCache<Group>::getEntry<std::string>(const std::string &) const;
+template std::shared_ptr<Group> DLL_PUBLIC EntCache<Group>::getEntry<gid_t>(const gid_t &) const;
template DLL_PUBLIC void EntCache<Group>::getName(const gid_t &, std::string *) const;
template DLL_PUBLIC void EntCache<Group>::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 <string>
#include <set>
-#include <IceUtil/Shared.h>
-#include <IceUtil/Handle.h>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <entryResolver.h>
-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<decltype(entry_t::id)> {
public:
typedef decltype(entry_t::id) id_t;
typedef decltype(entry_t::name) name_t;
- typedef IceUtil::Handle<entry_t> entry_ptr;
+ typedef std::shared_ptr<entry_t> entry_ptr;
EntCache();
virtual ~EntCache();
@@ -50,7 +48,7 @@ class EntCache : public EntryResolver<decltype(entry_t::id)> {
template<class key_t>
entry_ptr getEntryNoFill(const key_t &) const;
- typedef boost::multi_index::multi_index_container<IceUtil::Handle<entry_t>,
+ typedef boost::multi_index::multi_index_container<std::shared_ptr<entry_t>,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::tag<id_t>, BOOST_MULTI_INDEX_MEMBER(entry_t, const id_t, id)>,