From 35008d0efa0bcf0e7bcf4dd9a855fc8cabb96dcd Mon Sep 17 00:00:00 2001 From: Padraig O'Sullivan Date: Sat, 19 Sep 2009 12:59:14 -0400 Subject: [PATCH] Updated the destructor for the C++ example to correctly release memory. --- tests/cpp_example.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/cpp_example.cc b/tests/cpp_example.cc index 6feb26ab..a9977ca7 100644 --- a/tests/cpp_example.cc +++ b/tests/cpp_example.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -13,6 +14,16 @@ using namespace std; using namespace memcache; +class DeletePtrs +{ +public: + template + inline void operator()(const T *ptr) const + { + delete ptr; + } +}; + class MyCache { public: @@ -73,6 +84,7 @@ private: ~MyCache() { + for_each(clients.begin(), clients.end(), DeletePtrs()); clients.clear(); } -- 2.30.2