src/common/tag-list.cc
changeset 3299 4c42f0b977ad
parent 3236 8d25b503f270
child 3300 c8011a2a0c60
--- a/src/common/tag-list.cc	Sat Jun 21 08:05:21 2008 -0700
+++ b/src/common/tag-list.cc	Sat Jun 21 08:11:10 2008 -0700
@@ -25,6 +25,7 @@
 
 #define USE_FREE_LIST 1
 #define FREE_LIST_SIZE 1000
+#define OFFSET_MAX (2147483647)
 
 namespace ns3 {
 
@@ -99,7 +100,7 @@
 	}
     }
 }
-TagList::Iterator::Iterator (uint8_t *start, uint8_t *end, uint32_t offsetStart, uint32_t offsetEnd)
+TagList::Iterator::Iterator (uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd)
   : m_current (start),
     m_end (end),
     m_offsetStart (offsetStart),
@@ -158,7 +159,7 @@
 }
 
 TagBuffer
-TagList::Add (TypeId tid, uint32_t bufferSize, uint32_t start, uint32_t end)
+TagList::Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
 {
   NS_LOG_FUNCTION (this << tid << bufferSize << start << end);
   uint32_t spaceNeeded = m_used + bufferSize + 4 + 4 + 4 + 4;
@@ -191,7 +192,7 @@
 TagList::Add (const TagList &o)
 {
   NS_LOG_FUNCTION (this << &o);
-  TagList::Iterator i = o.Begin (0, 0xffffffff);
+  TagList::Iterator i = o.BeginAll ();
   while (i.HasNext ())
     {
       TagList::Iterator::Item item = i.Next ();
@@ -210,7 +211,16 @@
 }
 
 TagList::Iterator 
-TagList::Begin (uint32_t offsetStart, uint32_t offsetEnd) const
+TagList::BeginAll (void) const
+{
+  NS_LOG_FUNCTION (this);
+  // I am not totally sure but I might need to use 
+  // INT32_MIN instead of zero below.
+  return Begin (0, OFFSET_MAX);
+}
+
+TagList::Iterator 
+TagList::Begin (int32_t offsetStart, int32_t offsetEnd) const
 {
   NS_LOG_FUNCTION (this << offsetStart << offsetEnd);
   if (m_data == 0)
@@ -224,10 +234,10 @@
 }
 
 bool 
-TagList::IsDirtyAtEnd (uint32_t appendOffset)
+TagList::IsDirtyAtEnd (int32_t appendOffset)
 {
   NS_LOG_FUNCTION (this << appendOffset);
-  TagList::Iterator i = Begin (0, 0xffffffff);
+  TagList::Iterator i = BeginAll ();
   while (i.HasNext ())
     {
       TagList::Iterator::Item item = i.Next ();
@@ -240,10 +250,10 @@
 }
 
 bool 
-TagList::IsDirtyAtStart (uint32_t prependOffset)
+TagList::IsDirtyAtStart (int32_t prependOffset)
 {
   NS_LOG_FUNCTION (this << prependOffset);
-  TagList::Iterator i = Begin (0, 0xffffffff);
+  TagList::Iterator i = BeginAll ();
   while (i.HasNext ())
     {
       TagList::Iterator::Item item = i.Next ();
@@ -256,7 +266,7 @@
 }
 
 void 
-TagList::AddAtEnd (int32_t adjustment, uint32_t appendOffset)
+TagList::AddAtEnd (int32_t adjustment, int32_t appendOffset)
 {
   NS_LOG_FUNCTION (this << adjustment << appendOffset);
   if (adjustment == 0 && !IsDirtyAtEnd (appendOffset))
@@ -264,7 +274,7 @@
       return;
     }
   TagList list;
-  TagList::Iterator i = Begin (0, 0xffffffff);
+  TagList::Iterator i = BeginAll ();
   while (i.HasNext ())
     {
       TagList::Iterator::Item item = i.Next ();
@@ -290,7 +300,7 @@
 }
 
 void 
-TagList::AddAtStart (int32_t adjustment, uint32_t prependOffset)
+TagList::AddAtStart (int32_t adjustment, int32_t prependOffset)
 {
   NS_LOG_FUNCTION (this << adjustment << prependOffset);
   if (adjustment == 0 && !IsDirtyAtStart (prependOffset))
@@ -298,7 +308,7 @@
       return;
     }
   TagList list;
-  TagList::Iterator i = Begin (0, 0xffffffff);
+  TagList::Iterator i = BeginAll ();
   while (i.HasNext ())
     {
       TagList::Iterator::Item item = i.Next ();