fixed error with ulinfonew.m_ulReception when two LCs are created and only second one is used
authorNicola Baldo <nbaldo@cttc.es>
Mon, 02 Jul 2012 11:43:45 +0200
changeset 8888 d70ef2af2572
parent 8887 90cbd09c8ff6
child 8889 2f949197cf16
child 9334 e1b41c24fd32
fixed error with ulinfonew.m_ulReception when two LCs are created and only second one is used
src/lte/model/lte-enb-mac.cc
--- a/src/lte/model/lte-enb-mac.cc	Mon Jul 02 11:34:21 2012 +0200
+++ b/src/lte/model/lte-enb-mac.cc	Mon Jul 02 11:43:45 2012 +0200
@@ -579,8 +579,10 @@
       // new RNTI
       UlInfoListElement_s ulinfonew;
       ulinfonew.m_rnti = tag.GetRnti ();
-      std::vector <uint16_t>::iterator it = ulinfonew.m_ulReception.begin ();
-      ulinfonew.m_ulReception.insert (it + (tag.GetLcid () - 1), p->GetSize ());
+      // always allocate full size of ulReception vector, initializing all elements to 0
+      ulinfonew.m_ulReception.assign (MAX_LC_LIST+1, 0);
+      // set the element for the current LCID
+      ulinfonew.m_ulReception.at (tag.GetLcid ()) = p->GetSize ();
       ulinfonew.m_receptionStatus = UlInfoListElement_s::Ok;
       ulinfonew.m_tpc = 0; // Tx power control not implemented at this stage
       m_ulInfoListElements.insert (std::pair<uint16_t, UlInfoListElement_s > (tag.GetRnti (), ulinfonew));
@@ -588,15 +590,11 @@
     }
   else
     {
-      if ((*it).second.m_ulReception.size () < tag.GetLcid ())
-        {
-          std::vector <uint16_t>::iterator itV = (*it).second.m_ulReception.begin ();
-          (*it).second.m_ulReception.insert (itV + (tag.GetLcid () - 1), p->GetSize ());
-        }
-      else
-        {
-          (*it).second.m_ulReception.at (tag.GetLcid () - 1) += p->GetSize ();
-        }
+      // existing RNTI: we just set the value for the current
+      // LCID. Note that the corresponding element had already been
+      // allocated previously.
+      NS_ASSERT_MSG ((*it).second.m_ulReception.at (tag.GetLcid ()) == 0, "would overwrite previously written ulReception element");
+      (*it).second.m_ulReception.at (tag.GetLcid ()) = p->GetSize ();
       (*it).second.m_receptionStatus = UlInfoListElement_s::Ok;
     }