diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 41999c7db..38eb82c8c 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -280,6 +280,11 @@ Buffer::Buffer (uint32_t dataSize, bool initialize) bool Buffer::CheckInternalState (void) const { +#if 0 + // If you want to modify any code in this file, enable this checking code. + // Otherwise, there is not much point is enabling it because the + // current implementation has been fairly seriously tested and the cost + // of this constant checking is pretty high, even for a debug build. bool offsetsOk = m_start <= m_zeroAreaStart && m_zeroAreaStart <= m_zeroAreaEnd && @@ -300,6 +305,9 @@ Buffer::CheckInternalState (void) const ", " << (internalSizeOk?"true":"false") << " "); } return ok; +#else + return true; +#endif } void @@ -376,13 +384,6 @@ Buffer::~Buffer () } } -uint32_t -Buffer::GetSize (void) const -{ - NS_ASSERT (CheckInternalState ()); - return m_end - m_start; -} - Buffer::Iterator Buffer::Begin (void) const { diff --git a/src/common/buffer.h b/src/common/buffer.h index 2ec401b9b..6c1a1965c 100644 --- a/src/common/buffer.h +++ b/src/common/buffer.h @@ -393,7 +393,7 @@ public: /** * \return the number of bytes stored in this buffer. */ - uint32_t GetSize (void) const; + inline uint32_t GetSize (void) const; /** * \return a pointer to the start of the internal @@ -633,6 +633,11 @@ Buffer::Iterator::ReadU8 (void) } } +uint32_t +Buffer::GetSize (void) const +{ + return m_end - m_start; +} } // namespace ns3 diff --git a/src/common/packet.cc b/src/common/packet.cc index 5679a0320..521f69408 100644 --- a/src/common/packet.cc +++ b/src/common/packet.cc @@ -225,12 +225,6 @@ Packet::GetNixVector (void) const return m_nixVector; } -uint32_t -Packet::GetSize (void) const -{ - return m_buffer.GetSize (); -} - void Packet::AddHeader (const Header &header) { diff --git a/src/common/packet.h b/src/common/packet.h index 94ccdbfc6..a158a088e 100644 --- a/src/common/packet.h +++ b/src/common/packet.h @@ -254,7 +254,7 @@ public: * \returns the size in bytes of the packet (including the zero-filled * initial payload) */ - uint32_t GetSize (void) const; + inline uint32_t GetSize (void) const; /** * Add header to this packet. This method invokes the * Header::GetSerializedSize and Header::Serialize @@ -613,4 +613,14 @@ std::ostream& operator<< (std::ostream& os, const Packet &packet); } // namespace ns3 +namespace ns3 { + +uint32_t +Packet::GetSize (void) const +{ + return m_buffer.GetSize (); +} + +} // namespace ns3 + #endif /* PACKET_H */