diff --git a/src/memory/BHeapMemory.hpp b/src/memory/BHeapMemory.hpp index ec087d8bc74c2cfeef4eb8f87f952ce7e3f8af31..6a02117214b467efc93128df250cb77b2684118a 100644 --- a/src/memory/BHeapMemory.hpp +++ b/src/memory/BHeapMemory.hpp @@ -133,6 +133,16 @@ public: { return HeapMemory::size(); } + + /*! \brief Destroy the internal memory + * + * + */ + void destroy() + { + HeapMemory::destroy(); + buf_sz = 0; + } }; diff --git a/src/memory/HeapMemory.cpp b/src/memory/HeapMemory.cpp index 348656a11ebaeac85fe730a33d71f531fb278af4..7d423c8941806af7b4c5abc114448aa3ce5cbfc3 100644 --- a/src/memory/HeapMemory.cpp +++ b/src/memory/HeapMemory.cpp @@ -54,9 +54,8 @@ void HeapMemory::setAlignment(size_t align) this->alignement = align; } -/*! \brief destroy a chunk of memory +/*! \brief Destroy the internal memory * - * Destroy a chunk of memory * */ void HeapMemory::destroy() diff --git a/src/memory/HeapMemory_unit_tests.hpp b/src/memory/HeapMemory_unit_tests.hpp index 54df299a14759a53879e2de6d866f0fccb2ac377..f1fc1bc299567f71449537839f4794923d47e810 100644 --- a/src/memory/HeapMemory_unit_tests.hpp +++ b/src/memory/HeapMemory_unit_tests.hpp @@ -28,6 +28,8 @@ template<typename T> void test() //! [Allocate some memory and fill with data] T mem; + BOOST_REQUIRE_EQUAL(mem.size(),0ul); + mem.allocate(FIRST_ALLOCATION); BOOST_REQUIRE_EQUAL(mem.size(),FIRST_ALLOCATION); @@ -107,6 +109,14 @@ template<typename T> void test() BOOST_REQUIRE_EQUAL(ptr2[i],c); } + mem.destroy(); + + BOOST_REQUIRE_EQUAL(mem.size(),0ul); + + mem.allocate(FIRST_ALLOCATION); + + BOOST_REQUIRE_EQUAL(mem.size(),FIRST_ALLOCATION); + } } @@ -150,6 +160,14 @@ template<typename T> void Btest() BOOST_REQUIRE_EQUAL(mem.size(),1ul); //! [BShrink memory] + + mem.destroy(); + + BOOST_REQUIRE_EQUAL(mem.size(),0ul); + + mem.allocate(FIRST_ALLOCATION); + + BOOST_REQUIRE_EQUAL(mem.size(),FIRST_ALLOCATION); } BOOST_AUTO_TEST_CASE( use_heap_memory )