Commit c097d3c7 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2097] introduced the 'next' member; check alignment requirement

parent 6ddaa499
......@@ -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
......
......@@ -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;
......
......@@ -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());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment