From 9f68be78db17b2e07e526fe6a14fbe8ea5523cab Mon Sep 17 00:00:00 2001 From: Timothee Leclaire-Fournier Date: Fri, 1 Mar 2024 17:19:40 -0500 Subject: [PATCH] allocPool: Add destructor which cleans up. --- allocPool.hpp | 5 +++++ main.cpp | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/allocPool.hpp b/allocPool.hpp index 5f1a090..f57d437 100644 --- a/allocPool.hpp +++ b/allocPool.hpp @@ -24,6 +24,11 @@ public: initArray(defaultAllocNumbers); } + ~allocPool() { + for (auto i: vec) + delete i; + } + T *getPtr() { if (pivot == 0) resizeVec(); diff --git a/main.cpp b/main.cpp index 1d8375e..712f14f 100644 --- a/main.cpp +++ b/main.cpp @@ -34,6 +34,5 @@ int main() { std::cout << "Time (milliseconds) required for real allocations when constructing pool: " << std::chrono::duration_cast(endAlloc - startAlloc).count() << "\n"; - return 0; }