From 2cc8994ed6cf7a838319022e9b0776c7e449d33d Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Mon, 24 Oct 2016 16:35:09 -0400 Subject: [PATCH] mds: use unique_ptr unstable_bits_t in SimpleLock Signed-off-by: Patrick Donnelly --- src/mds/SimpleLock.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index 736fab5cb4c93..3b62f55b437cb 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -192,18 +192,17 @@ private: excl_client(-1) {} }; - mutable unstable_bits_t *_unstable; + mutable std::unique_ptr _unstable; bool have_more() const { return _unstable ? true : false; } unstable_bits_t *more() const { if (!_unstable) - _unstable = new unstable_bits_t; - return _unstable; + _unstable.reset(new unstable_bits_t); + return _unstable.get(); } void try_clear_more() { if (_unstable && _unstable->empty()) { - delete _unstable; - _unstable = NULL; + _unstable.reset(); } } @@ -223,12 +222,9 @@ public: parent(o), state(LOCK_SYNC), num_rdlock(0), - num_client_lease(0), - _unstable(NULL) + num_client_lease(0) {} - virtual ~SimpleLock() { - delete _unstable; - } + virtual ~SimpleLock() {} virtual bool is_scatterlock() const { return false; -- 2.39.5