From 9c3629c30b860933337eb826f5a752a61dc5c827 Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Mon, 19 Jan 2015 11:32:44 +0100 Subject: [PATCH] containers_cpp: fixed memory leak in test, check for memory leaks after tests --- containers_cpp/test/hazard_pointer_test.cc | 9 ++++++++- containers_cpp/test/hazard_pointer_test.h | 1 + containers_cpp/test/main.cc | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/containers_cpp/test/hazard_pointer_test.cc b/containers_cpp/test/hazard_pointer_test.cc index 33db76f..3c3883a 100644 --- a/containers_cpp/test/hazard_pointer_test.cc +++ b/containers_cpp/test/hazard_pointer_test.cc @@ -60,7 +60,8 @@ n_threads(static_cast Pre(&HazardPointerTest::HazardPointerTest1_Pre, this). Add( &HazardPointerTest::HazardPointerTest1_ThreadMethod, - this, static_cast(n_threads)); + this, static_cast(n_threads)). + Post(&HazardPointerTest::HazardPointerTest1_Post, this); } void HazardPointerTest::HazardPointerTest1_Pre() { @@ -75,6 +76,12 @@ void HazardPointerTest::HazardPointerTest1_Pre() { 1); } +void HazardPointerTest::HazardPointerTest1_Post() { + delete object_pool; + delete stack; + delete hp; +} + void HazardPointerTest::HazardPointerTest1_ThreadMethod() { unsigned int thread_index; embb_internal_thread_index(&thread_index); diff --git a/containers_cpp/test/hazard_pointer_test.h b/containers_cpp/test/hazard_pointer_test.h index 0ccfb99..d0e6bc2 100644 --- a/containers_cpp/test/hazard_pointer_test.h +++ b/containers_cpp/test/hazard_pointer_test.h @@ -59,6 +59,7 @@ class HazardPointerTest : public partest::TestCase { */ HazardPointerTest(); void HazardPointerTest1_Pre(); + void HazardPointerTest1_Post(); void HazardPointerTest1_ThreadMethod(); void DeletePointerCallback(embb::base::Atomic* to_delete); }; diff --git a/containers_cpp/test/main.cc b/containers_cpp/test/main.cc index 9919444..fe51456 100644 --- a/containers_cpp/test/main.cc +++ b/containers_cpp/test/main.cc @@ -39,6 +39,8 @@ #include #include +#include + #define COMMA , PT_MAIN("Data Structures C++") { @@ -67,4 +69,6 @@ PT_MAIN("Data Structures C++") { PT_RUN(embb::containers::test::ObjectPoolTest >); + + PT_EXPECT(embb_get_bytes_allocated() == 0); } -- libgit2 0.26.0