From: Radoslaw Zarzynski Date: Fri, 28 Sep 2018 12:57:10 +0000 (+0200) Subject: common: fix memory leaks in WeightedPriorityQueue. X-Git-Tag: v14.0.1~71^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=61395d44010f0ac1c183d030b244ae1ec0c8b99a;p=ceph.git common: fix memory leaks in WeightedPriorityQueue. Fixes: http://tracker.ceph.com/issues/36248 Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/common/WeightedPriorityQueue.h b/src/common/WeightedPriorityQueue.h index 4805495fa90e..91e16ea2aa5b 100644 --- a/src/common/WeightedPriorityQueue.h +++ b/src/common/WeightedPriorityQueue.h @@ -69,8 +69,11 @@ class WeightedPriorityQueue : public OpQueue K key; // klass ListPairs lp; Klass(K& k) : - key(k) - {} + key(k) { + } + ~Klass() { + lp.clear_and_dispose(DelItem()); + } friend bool operator< (const Klass &a, const Klass &b) { return a.key < b.key; } friend bool operator> (const Klass &a, const Klass &b) @@ -131,8 +134,11 @@ class WeightedPriorityQueue : public OpQueue Kit next; SubQueue(unsigned& p) : key(p), - next(klasses.begin()) - {} + next(klasses.begin()) { + } + ~SubQueue() { + klasses.clear_and_dispose(DelItem()); + } friend bool operator< (const SubQueue &a, const SubQueue &b) { return a.key < b.key; } friend bool operator> (const SubQueue &a, const SubQueue &b) @@ -197,8 +203,11 @@ class WeightedPriorityQueue : public OpQueue Queue() : total_prio(0), max_cost(0), - size(0) - {} + size(0) { + } + ~Queue() { + queues.clear_and_dispose(DelItem()); + } bool empty() const { return !size; }