]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2097] introduced the 'next' member; check alignment requirement
authorJINMEI Tatuya <jinmei@isc.org>
Mon, 13 Aug 2012 23:20:34 +0000 (16:20 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Mon, 13 Aug 2012 23:20:34 +0000 (16:20 -0700)
src/lib/datasrc/memory/rdataset.cc
src/lib/datasrc/memory/rdataset.h
src/lib/datasrc/memory/tests/rdataset_unittest.cc

index 4e3ffb240d37f2eb4fd71f4288e77be8661c965a..95ed5541082084112c05a2c851d4ffb257c96587 100644 (file)
@@ -94,6 +94,10 @@ RdataSet::RdataSet(RRType type_param, size_t rdata_count_param,
     // our assumption of the size of RdataSet holds.  If it's not the case
     // we should use the bare value instead of the class object.
     BOOST_STATIC_ASSERT(sizeof(type) == sizeof(uint16_t));
+
+    // Confirm we meet the alignment requirement for RdataEncoder
+    // ("this + 1" should be safely passed to the encoder).
+    BOOST_STATIC_ASSERT(sizeof(RdataSet) % sizeof(uint16_t) == 0);
 }
 
 } // namespace memory
index 946294ba6a20f7edcdfc5146b035d1a60d6be703..2938dc9cb40b8a5b83582d7cb39f6f7b005fa9c9 100644 (file)
@@ -22,6 +22,8 @@
 #include <dns/rrset.h>
 #include <dns/rrttl.h>
 
+#include <boost/interprocess/offset_ptr.hpp>
+
 #include <stdint.h>
 
 namespace isc {
@@ -38,6 +40,14 @@ public:
     static void destroy(util::MemorySegment& mem_sgmt, dns::RRClass rrclass,
                         RdataSet* rdataset);
 
+    typedef boost::interprocess::offset_ptr<RdataSet> RdataSetPtr;
+    typedef boost::interprocess::offset_ptr<const RdataSet> ConstRdataSetPtr;
+
+    // Note: the size and order of the members are important.  Don't change
+    // them unless there's strong reason for that and the consequences are
+    // considered.
+
+    RdataSetPtr next;
     const dns::RRType type;
 private:
     const uint16_t sig_rdata_count : 3;
index c91476536ba840ee836de92a2a4140d774814a27..9122644376f1209a5e26486b8e704b6a1f7e593e 100644 (file)
@@ -63,6 +63,7 @@ TEST_F(RdataSetTest, create) {
     // would detect any memory leak)
     RdataSet* rdataset = RdataSet::create(mem_sgmt_, encoder_, a_rrset_,
                                           ConstRRsetPtr());
+    EXPECT_FALSE(rdataset->next); // by default the next pointer should be NULL
     EXPECT_EQ(RRType::A(), rdataset->type);
     EXPECT_EQ(RRTTL(1076895760), restoreTTL(rdataset->getTTLData()));
     EXPECT_EQ(1, rdataset->getRdataCount());