BIND 10 trac2831, updated. 36389eed513783f9ccb0b7248fe0c5909ef2a36d [2831] Iterate over the source data instead of using redundant data
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Apr 12 14:06:24 UTC 2013
The branch, trac2831 has been updated
via 36389eed513783f9ccb0b7248fe0c5909ef2a36d (commit)
via 5728c385420fdb47dd463c7737ee0cf447609c81 (commit)
via caa37a99fc07eec6e88c6a829d000b2cb1baf4d6 (commit)
from ba0d6139cadca933ebbaaa7f5016480154331ae6 (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 36389eed513783f9ccb0b7248fe0c5909ef2a36d
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Apr 12 19:35:57 2013 +0530
[2831] Iterate over the source data instead of using redundant data
The order is now non-reverse (i.e., sorted order), but it is anyway
better we delete in the same order we insert so the first in is first
out.
commit 5728c385420fdb47dd463c7737ee0cf447609c81
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Apr 12 19:33:04 2013 +0530
[2831] Make minor comment updates
commit caa37a99fc07eec6e88c6a829d000b2cb1baf4d6
Author: Mukund Sivaraman <muks at isc.org>
Date: Thu Apr 11 19:28:52 2013 +0530
[2381] Change more occurences of 0 to NULL
-----------------------------------------------------------------------
Summary of changes:
src/lib/util/memory_segment.h | 11 +++++-----
.../util/tests/memory_segment_common_unittest.cc | 2 +-
.../util/tests/memory_segment_mapped_unittest.cc | 23 ++++++++++----------
3 files changed, 18 insertions(+), 18 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/util/memory_segment.h b/src/lib/util/memory_segment.h
index ae7bc91..e62c9df 100644
--- a/src/lib/util/memory_segment.h
+++ b/src/lib/util/memory_segment.h
@@ -90,9 +90,9 @@ public:
/// ComplicatedStuff* stuff = NULL;
/// while (!stuff) { // this must eventually succeed or result in bad_alloc
/// try {
- /// // create() is a factory method, takes a memory segment
+ /// // create() is a factory method that takes a memory segment
/// // and calls allocate() on it multiple times. create()
- /// // provides exception guarantee in that any intermediately
+ /// // provides an exception guarantee that any intermediately
/// // allocated memory will be properly deallocate()-ed on
/// // exception.
/// stuff = ComplicatedStuff::create(mem_segment);
@@ -107,9 +107,10 @@ public:
/// version of this method with a way to tell the caller the reason of
/// any failure (whether it's really out of memory or just due to growing
/// the segment). That would be more convenient if the caller wants to
- /// deal with the failures per call basis rather than as a set of calls
- /// like the above example. At the moment, we don't expect to have
- /// such use cases, so we only provide the exception version.
+ /// deal with the failures on a per-call basis rather than as a set
+ /// of calls like in the above example. At the moment, we don't expect
+ /// to have such use-cases, so we only provide the exception
+ /// version.
///
/// \throw std::bad_alloc The implementation cannot allocate the
/// requested storage.
diff --git a/src/lib/util/tests/memory_segment_common_unittest.cc b/src/lib/util/tests/memory_segment_common_unittest.cc
index d47a3e2..3810e0a 100644
--- a/src/lib/util/tests/memory_segment_common_unittest.cc
+++ b/src/lib/util/tests/memory_segment_common_unittest.cc
@@ -64,7 +64,7 @@ checkSegmentNamedAddress(MemorySegment& segment, bool out_of_segment_ok) {
EXPECT_FALSE(segment.clearNamedAddress("test address"));
// Setting NULL is okay.
- EXPECT_FALSE(segment.setNamedAddress("null address", 0));
+ EXPECT_FALSE(segment.setNamedAddress("null address", NULL));
EXPECT_EQ(static_cast<void*>(NULL),
segment.getNamedAddress("null address"));
diff --git a/src/lib/util/tests/memory_segment_mapped_unittest.cc b/src/lib/util/tests/memory_segment_mapped_unittest.cc
index b1e3ab5..18173e8 100644
--- a/src/lib/util/tests/memory_segment_mapped_unittest.cc
+++ b/src/lib/util/tests/memory_segment_mapped_unittest.cc
@@ -24,6 +24,7 @@
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/scoped_ptr.hpp>
+#include <boost/foreach.hpp>
#include <stdint.h>
#include <cstdlib>
@@ -89,7 +90,7 @@ TEST_F(MemorySegmentMappedTest, createAndModify) {
EXPECT_TRUE(segment_->allMemoryDeallocated());
void* ptr = segment_->allocate(1024);
- EXPECT_NE(static_cast<void*>(0), ptr);
+ EXPECT_NE(static_cast<void*>(NULL), ptr);
// Now, we have an allocation:
EXPECT_FALSE(segment_->allMemoryDeallocated());
@@ -315,19 +316,20 @@ TEST_F(MemorySegmentMappedTest, namedAddress) {
segment_.reset();
boost::interprocess::file_mapping::remove(mapped_file);
segment_.reset(new MemorySegmentMapped(mapped_file, OPEN_OR_CREATE));
- std::map<std::string, std::vector<uint8_t> > data_list;
+
+ typedef std::map<std::string, std::vector<uint8_t> > TestData;
+
+ TestData data_list;
data_list["data1"] =
std::vector<uint8_t>(80); // arbitrarily chosen small data
data_list["data2"] =
- std::vector<uint8_t>(5000); // larger than usual segment sz
+ std::vector<uint8_t>(5000); // larger than usual segment size
data_list["data3"] =
std::vector<uint8_t>(65535); // bigger than most usual data
bool grown = false;
// Allocate memory and store data
- for (std::map<std::string, std::vector<uint8_t> >::iterator it
- = data_list.begin();
- it != data_list.end();
+ for (TestData::iterator it = data_list.begin(); it != data_list.end();
++it)
{
std::vector<uint8_t>& data = it->second;
@@ -348,17 +350,14 @@ TEST_F(MemorySegmentMappedTest, namedAddress) {
// Confirm there's at least one segment extension
EXPECT_TRUE(grown);
// Check named data are still valid
- for (std::map<std::string, std::vector<uint8_t> >::iterator it
- = data_list.begin();
- it != data_list.end();
+ for (TestData::iterator it = data_list.begin(); it != data_list.end();
++it)
{
checkNamedData(it->first, it->second, *segment_);
}
// Confirm they are still valid, while we shrink the segment
- const char* const names[] = { "data3", "data2", "data1", NULL };
- for (int i = 0; names[i]; ++i) {
- checkNamedData(names[i], data_list[names[i]], *segment_, true);
+ BOOST_FOREACH(TestData::value_type e, data_list) {
+ checkNamedData(e.first, e.second, *segment_, true);
segment_->shrinkToFit();
}
}
More information about the bind10-changes
mailing list