From: Padraig O'Sullivan Date: Sat, 19 Sep 2009 16:59:14 +0000 (-0400) Subject: Updated the destructor for the C++ example to correctly release memory. X-Git-Tag: 0.34~13^2~10 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=35008d0efa0bcf0e7bcf4dd9a855fc8cabb96dcd;p=m6w6%2Flibmemcached Updated the destructor for the C++ example to correctly release memory. --- 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(); }