The class stores pointers and owns the memory they point to. Memory is
allocated in constructor and freed in destructor. But copying these
pointers between objects causes double free in destructor. The poiners
should not be copied, only moved.
Now CynaraAdminPolicy will provide custom move constructor. It will be
used by default, since default copy constructor is now deleted.
Change-Id: If6c49184318c54574caff8af74b336dd1c8ddd2f
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
}
}
+CynaraAdminPolicy::CynaraAdminPolicy(CynaraAdminPolicy &&that)
+{
+ bucket = that.bucket;
+ client = that.client;
+ user = that.user;
+ privilege = that.privilege;
+ result_extra = that.result_extra;
+ result = that.result;
+
+ that.bucket = nullptr;
+ that.client = nullptr;
+ that.user = nullptr;
+ that.privilege = nullptr;
+ that.result_extra = nullptr;
+}
+
CynaraAdminPolicy::~CynaraAdminPolicy()
{
free(this->bucket);
const std::string &privilege, const std::string &goToBucket,
const std::string &bucket = std::string(CYNARA_ADMIN_DEFAULT_BUCKET));
+ /* Don't provide copy constructor, it would cause pointer trouble. */
+ CynaraAdminPolicy(const CynaraAdminPolicy &that) = delete;
+
+ /* Move constructor is the way to go. */
+ CynaraAdminPolicy(CynaraAdminPolicy &&that);
+
~CynaraAdminPolicy();
};