fix field ordering.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 05 Jun 2007 16:33:45 +0200
changeset 839 baa491a253d7
parent 838 186decaef5c2
child 840 e473844a60c2
fix field ordering.
src/common/packet-history.cc
--- a/src/common/packet-history.cc	Tue Jun 05 15:59:07 2007 +0200
+++ b/src/common/packet-history.cc	Tue Jun 05 16:33:45 2007 +0200
@@ -603,8 +603,8 @@
       Append16 (next, &buffer);
       Append16 (prev, &buffer);
       if (TryToAppend (typeUid, &buffer, end) &&
-          TryToAppend (chunkUid, &buffer, end) &&
-          TryToAppend (size, &buffer, end))
+          TryToAppend (size, &buffer, end) &&
+          TryToAppend (chunkUid, &buffer, end))
         {
           uintptr_t written = buffer - start;
           NS_ASSERT (written <= 0xffff);
@@ -616,10 +616,20 @@
             } 
           else if (atStart)
             {
+              NS_ASSERT (m_begin != 0xffff);
+              // overwrite the prev field of the previous head of the list.
+              uint8_t *previousHead = &m_data->m_data[m_begin] + 2;
+              Append16 (m_used, &previousHead);
+              // update the head of list to the new node.
               m_begin = m_used;
             }
           else
             {
+              NS_ASSERT (m_end != 0xffff);
+              // overwrite the next field of the previous tail of the list.
+              uint8_t *previousTail = &m_data->m_data[m_end];
+              Append16 (m_used, &previousTail);
+              // update the tail of the list to the new node.
               m_end = m_used;
             }
           NS_ASSERT (m_end != 0xffff);
@@ -631,8 +641,8 @@
     }
 
   uint32_t n = GetUleb128Size (typeUid);
+  n += GetUleb128Size (size);
   n += GetUleb128Size (chunkUid);
-  n += GetUleb128Size (size);
   n += 2 + 2;
   ReserveCopy (n);
   goto append;
@@ -793,7 +803,7 @@
     {
       return;
     }
-  AddSmall (true, uid, size);
+  AddSmall (false, uid, size);
 }
 void 
 PacketHistory::RemoveTrailer (uint32_t uid, Chunk const & trailer, uint32_t size)