rename NodeList::GetNode to NodeList::PeekNode to avoid memory leaks. Call Dispose from NodeListPriv::~NodeListPriv
This commit is contained in:
@@ -52,7 +52,7 @@ public:
|
||||
{
|
||||
NodeList::NodeIndex nodeIndex;
|
||||
context.Get (nodeIndex);
|
||||
m_filestr << "node=" << NodeList::GetNode (nodeIndex)->GetId () << " ";
|
||||
m_filestr << "node=" << NodeList::PeekNode (nodeIndex)->GetId () << " ";
|
||||
Ipv4::InterfaceIndex interfaceIndex;
|
||||
context.Get (interfaceIndex);
|
||||
m_filestr << "interface=" << interfaceIndex << " ";
|
||||
|
||||
@@ -110,7 +110,7 @@ AsciiTrace::LogDevQueue (TraceContext const &context, Packet const &packet)
|
||||
m_os << Simulator::Now ().GetSeconds () << " ";
|
||||
NodeList::NodeIndex nodeIndex;
|
||||
context.Get (nodeIndex);
|
||||
m_os << "node=" << NodeList::GetNode (nodeIndex)->GetId () << " ";
|
||||
m_os << "node=" << NodeList::PeekNode (nodeIndex)->GetId () << " ";
|
||||
Ipv4::InterfaceIndex interfaceIndex;
|
||||
context.Get (interfaceIndex);
|
||||
m_os << "interface=" << interfaceIndex << " ";
|
||||
@@ -124,7 +124,7 @@ AsciiTrace::LogDevRx (TraceContext const &context, Packet &p)
|
||||
m_os << "r " << Simulator::Now ().GetSeconds () << " ";
|
||||
NodeList::NodeIndex nodeIndex;
|
||||
context.Get (nodeIndex);
|
||||
m_os << "node=" << NodeList::GetNode (nodeIndex)->GetId () << " ";
|
||||
m_os << "node=" << NodeList::PeekNode (nodeIndex)->GetId () << " ";
|
||||
Ipv4::InterfaceIndex interfaceIndex;
|
||||
context.Get (interfaceIndex);
|
||||
m_os << "interface=" << interfaceIndex << " ";
|
||||
|
||||
@@ -69,6 +69,7 @@ NodeListPriv::~NodeListPriv ()
|
||||
i != m_nodes.end (); i++)
|
||||
{
|
||||
Node *node = *i;
|
||||
node->Dispose ();
|
||||
node->Unref ();
|
||||
}
|
||||
m_nodes.erase (m_nodes.begin (), m_nodes.end ());
|
||||
@@ -94,13 +95,6 @@ NodeListPriv::End (void)
|
||||
{
|
||||
return m_nodes.end ();
|
||||
}
|
||||
Node *
|
||||
NodeListPriv::GetNode (uint32_t n)
|
||||
{
|
||||
Node *node = m_nodes[n];
|
||||
node->Ref ();
|
||||
return node;
|
||||
}
|
||||
uint32_t
|
||||
NodeListPriv::GetNNodes (void)
|
||||
{
|
||||
@@ -153,9 +147,9 @@ NodeList::CreateTraceResolver (TraceContext const &context)
|
||||
return SimulationSingleton<NodeListPriv>::Get ()->CreateTraceResolver (context);
|
||||
}
|
||||
Node *
|
||||
NodeList::GetNode (uint32_t n)
|
||||
NodeList::PeekNode (uint32_t n)
|
||||
{
|
||||
return SimulationSingleton<NodeListPriv>::Get ()->GetNode (n);
|
||||
return SimulationSingleton<NodeListPriv>::Get ()->PeekNode (n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
static Iterator End (void);
|
||||
static TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
|
||||
static Node *GetNode (uint32_t n);
|
||||
static Node *PeekNode (uint32_t n);
|
||||
};
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -84,7 +84,7 @@ PcapTrace::LogIp (TraceContext const &context, Packet const &p, uint32_t interfa
|
||||
{
|
||||
NodeList::NodeIndex nodeIndex;
|
||||
context.Get (nodeIndex);
|
||||
uint32_t nodeId = NodeList::GetNode (nodeIndex)->GetId ();
|
||||
uint32_t nodeId = NodeList::PeekNode (nodeIndex)->GetId ();
|
||||
PcapWriter *writer = GetStream (nodeId, interfaceIndex);
|
||||
writer->WritePacket (p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user