bug 217: avoid unsigned/signed confusion. Used signed all the time.
--- 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 ();
--- a/src/common/tag-list.h Sat Jun 21 08:05:21 2008 -0700
+++ b/src/common/tag-list.h Sat Jun 21 08:11:10 2008 -0700
@@ -76,8 +76,8 @@
{
TypeId tid;
uint32_t size;
- uint32_t start;
- uint32_t end;
+ int32_t start;
+ int32_t end;
TagBuffer buf;
Item (TagBuffer buf);
private:
@@ -89,16 +89,16 @@
uint32_t GetOffsetStart (void) const;
private:
friend class TagList;
- Iterator (uint8_t *start, uint8_t *end, uint32_t offsetStart, uint32_t offsetEnd);
+ Iterator (uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd);
void PrepareForNext (void);
uint8_t *m_current;
uint8_t *m_end;
- uint32_t m_offsetStart;
- uint32_t m_offsetEnd;
+ int32_t m_offsetStart;
+ int32_t m_offsetEnd;
uint32_t m_nextTid;
uint32_t m_nextSize;
- uint32_t m_nextStart;
- uint32_t m_nextEnd;
+ int32_t m_nextStart;
+ int32_t m_nextEnd;
};
TagList ();
@@ -116,7 +116,7 @@
*
*
*/
- TagBuffer Add (TypeId tid, uint32_t bufferSize, uint32_t start, uint32_t end);
+ TagBuffer Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end);
/**
* \param o the other list of tags to aggregate.
@@ -138,24 +138,25 @@
* in this list: the boundaries of each tag as reported by their start and
* end offsets will be included within the input offsetStart and offsetEnd.
*/
- TagList::Iterator Begin (uint32_t offsetStart, uint32_t offsetEnd) const;
+ TagList::Iterator Begin (int32_t offsetStart, int32_t offsetEnd) const;
/**
* Adjust the offsets stored internally by the adjustment delta and
* make sure that all offsets are smaller than appendOffset which represents
* the location where new bytes have been added to the byte buffer.
*/
- void AddAtEnd (int32_t adjustment, uint32_t appendOffset);
+ void AddAtEnd (int32_t adjustment, int32_t appendOffset);
/**
* Adjust the offsets stored internally by the adjustment delta and
* make sure that all offsets are bigger than prependOffset which represents
* the location where new bytes have been added to the byte buffer.
*/
- void AddAtStart (int32_t adjustment, uint32_t prependOffset);
+ void AddAtStart (int32_t adjustment, int32_t prependOffset);
private:
- bool IsDirtyAtEnd (uint32_t appendOffset);
- bool IsDirtyAtStart (uint32_t prependOffset);
+ bool IsDirtyAtEnd (int32_t appendOffset);
+ bool IsDirtyAtStart (int32_t prependOffset);
+ TagList::Iterator BeginAll (void) const;
struct TagListData *Allocate (uint32_t size);
void Deallocate (struct TagListData *data);