From: Patrick Donnelly Date: Mon, 24 Oct 2016 15:51:50 +0000 (-0400) Subject: mds: use unique_ptr bufferlist in inline_data_t X-Git-Tag: v11.1.0~170^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ed0d099a335377f349a8475bf3b1fbbc1ddbf28a;p=ceph.git mds: use unique_ptr bufferlist in inline_data_t Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index a384fbcda04b..b3f4f14bf8ab 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -415,29 +415,25 @@ inline bool operator==(const client_writeable_range_t& l, struct inline_data_t { private: - bufferlist *blp; + std::unique_ptr blp; public: version_t version; void free_data() { - delete blp; - blp = NULL; + blp.reset(); } bufferlist& get_data() { if (!blp) - blp = new bufferlist; + blp.reset(new bufferlist); return *blp; } size_t length() const { return blp ? blp->length() : 0; } - inline_data_t() : blp(0), version(1) {} - inline_data_t(const inline_data_t& o) : blp(0), version(o.version) { + inline_data_t() : version(1) {} + inline_data_t(const inline_data_t& o) : version(o.version) { if (o.blp) get_data() = *o.blp; } - ~inline_data_t() { - free_data(); - } inline_data_t& operator=(const inline_data_t& o) { version = o.version; if (o.blp) @@ -449,7 +445,7 @@ public: bool operator==(const inline_data_t& o) const { return length() == o.length() && (length() == 0 || - (*const_cast(blp) == *const_cast(o.blp))); + (*const_cast(blp.get()) == *const_cast(o.blp.get()))); } bool operator!=(const inline_data_t& o) const { return !(*this == o);