diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-10-31 15:01:29 +0000 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-10-31 15:14:44 +0000 |
commit | c570e74384a63b88d38d7697be435dd8de130ac8 (patch) | |
tree | 0abeb2fcd3d058155a37f31e1b9b23a89c1ab78d /libtransport/src/hicn/transport/utils/object_pool.h | |
parent | fc6dfe9f7ee02834ae1e6f56e0aaee36ac3e88dd (diff) |
[HICN-371] Solve memory leaks in libtransport.
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Change-Id: I654843c3361c7bdb4b160f2441f08e8d91e97384
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/utils/object_pool.h')
-rw-r--r-- | libtransport/src/hicn/transport/utils/object_pool.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libtransport/src/hicn/transport/utils/object_pool.h b/libtransport/src/hicn/transport/utils/object_pool.h index e34730e81..e8f837753 100644 --- a/libtransport/src/hicn/transport/utils/object_pool.h +++ b/libtransport/src/hicn/transport/utils/object_pool.h @@ -47,7 +47,12 @@ class ObjectPool { ObjectPool() : destructor_(false) {} - ~ObjectPool() { destructor_ = true; } + ~ObjectPool() { + destructor_ = true; + for (auto &ptr : object_pool_) { + ptr.reset(); + } + } std::pair<bool, Ptr> get() { if (object_pool_.empty()) { @@ -65,6 +70,8 @@ class ObjectPool { if (TRANSPORT_EXPECT_TRUE(!destructor_)) { object_pool_.emplace_back(makePtr(object)); + } else { + delete object; } } |