aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/hicn/transport/utils/object_pool.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/hicn/transport/utils/object_pool.h')
-rw-r--r--libtransport/src/hicn/transport/utils/object_pool.h9
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;
}
}