--- a/src/common/buffer.cc Tue Sep 11 13:53:39 2007 +0200
+++ b/src/common/buffer.cc Tue Sep 11 14:10:02 2007 +0200
@@ -668,35 +668,6 @@
}
}
void
-Buffer::Iterator::WriteU8 (uint8_t data)
-{
- if (m_current < m_dataStart)
- {
- // XXX trying to write outside of data area
- NS_ASSERT (false);
- }
- else if (m_current < m_zeroStart)
- {
- m_data[m_current] = data;
- m_current++;
- }
- else if (m_current < m_zeroEnd)
- {
- // XXX trying to write in zero area
- NS_ASSERT (false);
- }
- else if (m_current < m_dataEnd)
- {
- m_data[m_current - (m_zeroEnd-m_zeroStart)] = data;
- m_current++;
- }
- else
- {
- // XXX trying to write outside of data area
- NS_ASSERT (false);
- }
-}
-void
Buffer::Iterator::WriteU16 (uint16_t data)
{
WriteU8 (data & 0xff);
--- a/src/common/buffer.h Tue Sep 11 13:53:39 2007 +0200
+++ b/src/common/buffer.h Tue Sep 11 14:10:02 2007 +0200
@@ -87,7 +87,7 @@
* Write the data in buffer and avance the iterator position
* by one byte.
*/
- void WriteU8 (uint8_t data);
+ inline void WriteU8 (uint8_t data);
/**
* \param data data to write in buffer
* \param len number of times data must be written in buffer
@@ -348,4 +348,30 @@
} // namespace ns3
+#include "ns3/assert.h"
+
+namespace ns3 {
+
+void
+Buffer::Iterator::WriteU8 (uint8_t data)
+{
+ NS_ASSERT (m_current >= m_dataStart &&
+ !(m_current >= m_zeroStart && m_current <= m_zeroEnd) &&
+ m_current <= m_dataEnd);
+
+ if (m_current < m_zeroStart)
+ {
+ m_data[m_current] = data;
+ m_current++;
+ }
+ else
+ {
+ m_data[m_current - (m_zeroEnd-m_zeroStart)] = data;
+ m_current++;
+ }
+}
+
+
+} // namespace ns3
+
#endif /* BUFFER_H */