BIND 10 trac2088, updated. c9f90e89db5b8cae1a79896700cea84abe4a9e55 [2088] Deallocate all memory in TestBadDeallocate unit test

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Jul 13 03:53:21 UTC 2012


The branch, trac2088 has been updated
       via  c9f90e89db5b8cae1a79896700cea84abe4a9e55 (commit)
       via  59c5e16d4fae5a18681580ca6948999d60ee7e5d (commit)
      from  25cc38bbd45cca618c0f073b743882865ebc1d64 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c9f90e89db5b8cae1a79896700cea84abe4a9e55
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Jul 13 09:22:57 2012 +0530

    [2088] Deallocate all memory in TestBadDeallocate unit test

commit 59c5e16d4fae5a18681580ca6948999d60ee7e5d
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Jul 13 09:21:26 2012 +0530

    [2088] Add comments about size argument to deallocate()

-----------------------------------------------------------------------

Summary of changes:
 src/lib/util/memory_segment.h                      |    6 +++++-
 .../util/tests/memory_segment_local_unittest.cc    |    6 ++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

-----------------------------------------------------------------------
diff --git a/src/lib/util/memory_segment.h b/src/lib/util/memory_segment.h
index d8b718a..97d2e02 100644
--- a/src/lib/util/memory_segment.h
+++ b/src/lib/util/memory_segment.h
@@ -44,7 +44,11 @@ public:
     /// \brief Free/release a segment of memory.
     ///
     /// This method may throw <code>isc::OutOfRange</code> if \c size is
-    /// not equal to the originally allocated size.
+    /// not equal to the originally allocated size. \c size could be
+    /// used by some implementations such as a slice allocator, where
+    /// freeing memory also requires the size to be specified. We also
+    /// use this argument in some implementations to test if all allocated
+    /// memory was deallocated properly.
     ///
     /// \param ptr Pointer to the block of memory to free/release. This
     /// should be equal to a value returned by <code>allocate()</code>.
diff --git a/src/lib/util/tests/memory_segment_local_unittest.cc b/src/lib/util/tests/memory_segment_local_unittest.cc
index 08787ad..a18a9b2 100644
--- a/src/lib/util/tests/memory_segment_local_unittest.cc
+++ b/src/lib/util/tests/memory_segment_local_unittest.cc
@@ -84,6 +84,12 @@ TEST(MemorySegmentLocal, TestBadDeallocate) {
     // This should throw as the size passed to deallocate() is larger
     // than what was allocated.
     EXPECT_THROW(segment->deallocate(ptr, 2048), isc::OutOfRange);
+
+    // This should not throw
+    EXPECT_NO_THROW(segment->deallocate(ptr, 1024));
+
+    // Now, we have an deallocated everything:
+    EXPECT_TRUE(segment->allMemoryDeallocated());
 }
 
 TEST(MemorySegmentLocal, TestNullDeallocate) {



More information about the bind10-changes mailing list