From ed0d099a335377f349a8475bf3b1fbbc1ddbf28a Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Mon, 24 Oct 2016 11:51:50 -0400 Subject: [PATCH] mds: use unique_ptr bufferlist in inline_data_t Signed-off-by: Patrick Donnelly --- src/mds/mdstypes.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index a384fbcda04..b3f4f14bf8a 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); -- 2.47.3