您的位置:首页 > 其它

Record of NS_Simulator bug fixed.

2012-04-07 22:15 162 查看
In "RunController.h":

/*

Modify in 2012_04_07:

@1: modify the ~RunController(), in which MNs can be destruct without any obstruct, and guide MNs to destroy their pkts in buffer.

*/

In "Node.h":

/*

Modify in 2012_04_07:

@1: modify the Clear_MNs_Pkts(), and add the DestroyPkts() function into it;

@2: modify the ReceiveAndStorePkt( int nPktType, char* pPkt), every MN should keep its own pkts buffer, not the pointer to the source MN's newed pkt.

*/

Display the modified ReceiveAndStorePkt function here:

// ---------------- ReceiveAndStorePkt:

// Create a new Packet depend on the pSrcPkt, and store it into its buffer Storage.

void MNode::ReceiveAndStorePkt( _in int nPktType, _in char* pSrcPkt)

{

assert( NULL != pSrcPkt);

if ( NULL == pSrcPkt)

{

LogFile::instance()->m_ofErrLog << "Error: in MNode::StorePkt, NULL == pSrcPkt.\n";

return;

}

// 1) Copy and Store the received Pkt, !! must create a new pPkt_dataPiece here.

char* pPktData = new char[PIECESIZE+1];

memset( pPktData, 0, PIECESIZE+1 );

memcpy( pPktData, pSrcPkt, PIECESIZE );

this->m_map_PktID__PktType_pData.insert( make_pair(m_nPktID, make_pair( nPktType, pPktData )) );

m_nPktID++; // every time, the PktID++.

// ...

}

// ------------- ReceiveAndStorePkt:~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: