fix last leaks with new refcounted mechanism

This commit is contained in:
Mathieu Lacage committed 2007-05-03 00:31:04 +02:00
1 parent d1edc4f0e3
commit 87b3408a0e
11 files changed
+43 -63

No files matched your search

+1
View File
@@ -56,6 +56,7 @@ ApplicationList* ApplicationList::Copy(Node * n) const
void
ApplicationList::Add(Application* a)
{
a->Ref ();
m_apps.push_back(a);
}
+14 -4
View File
@@ -41,9 +41,17 @@ InternetNode::InternetNode()
m_applicationList = new ApplicationList(this);
m_l3Demux = new L3Demux(this);
m_ipv4L4Demux = new Ipv4L4Demux(this);
m_l3Demux->Insert (Ipv4 (this));
m_l3Demux->Insert (Arp (this));
m_ipv4L4Demux->Insert (Udp (this));
Ipv4 *ipv4 = new Ipv4 (this);
Arp *arp = new Arp (this);
Udp *udp = new Udp (this);
m_l3Demux->Insert (ipv4);
m_l3Demux->Insert (arp);
m_ipv4L4Demux->Insert (udp);
ipv4->Unref ();
arp->Unref ();
udp->Unref ();
}
InternetNode::~InternetNode ()
@@ -161,7 +169,9 @@ InternetNode::DoAddDevice (NetDevice *device) const
bool
InternetNode::ReceiveFromDevice (NetDevice *device, const Packet &p, uint16_t protocolNumber) const
{
L3Protocol *target = GetL3Demux()->PeekProtocol (protocolNumber);
L3Demux *demux = GetL3Demux();
L3Protocol *target = demux->PeekProtocol (protocolNumber);
demux->Unref ();
if (target != 0)
{
Packet packet = p;
+4 -15
View File
@@ -56,16 +56,6 @@ Ipv4L4Demux::Dispose (void)
}
}
Ipv4L4Demux*
Ipv4L4Demux::Copy(Node *node) const
{
Ipv4L4Demux * copy = new Ipv4L4Demux(node);
for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
{
copy->Insert(*(*i));
}
return copy;
}
TraceResolver *
Ipv4L4Demux::CreateTraceResolver (TraceContext const &context)
{
@@ -83,12 +73,11 @@ Ipv4L4Demux::CreateTraceResolver (TraceContext const &context)
}
return resolver;
}
Ipv4L4Protocol*
Ipv4L4Demux::Insert(const Ipv4L4Protocol&protocol)
void
Ipv4L4Demux::Insert(Ipv4L4Protocol *protocol)
{
Ipv4L4Protocol* copy = protocol.Copy(m_node); // Make a copy of the protocol
m_protocols.push_back (copy);
return copy;
protocol->Ref ();
m_protocols.push_back (protocol);
}
Ipv4L4Protocol*
Ipv4L4Demux::PeekProtocol(int protocolNumber)
+1 -7
View File
@@ -47,12 +47,6 @@ public:
void Dispose (void);
/**
* \param node the node on which the returned copy will run.
* \returns a deep copy of this L4 Demux.
*/
Ipv4L4Demux* Copy(Node *node) const;
/**
* \param context the trace context to use to construct the
* TraceResolver to return
@@ -71,7 +65,7 @@ public:
* a working L4 Protocol and returned from this method.
* The caller does not get ownership of the returned pointer.
*/
Ipv4L4Protocol* Insert(const Ipv4L4Protocol&protocol);
void Insert(Ipv4L4Protocol *protocol);
/**
* \param protocolNumber number of protocol to lookup
* in this L4 Demux
-7
View File
@@ -62,13 +62,6 @@ public:
*/
int GetVersion() const;
/**
* \param node the node on which the copy should be running
* \returns a new instance of this L4 Protocol.
*
* Perform a deep copy of the L4 Protocol
*/
virtual Ipv4L4Protocol* Copy(Node *node) const = 0;
virtual TraceResolver *CreateTraceResolver (TraceContext const &context) = 0;
/**
+3 -15
View File
@@ -73,22 +73,10 @@ L3Demux::CreateTraceResolver (TraceContext const &context) const
return resolver;
}
L3Demux* L3Demux::Copy(Node *node) const
void L3Demux::Insert(L3Protocol *p)
{
L3Demux *copy = new L3Demux (node);
for (L3Map_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
{
copy->Insert(*i->second);
}
return copy;
}
L3Protocol* L3Demux::Insert(const L3Protocol& l3p)
{
L3Protocol* l = l3p.Copy(m_node); // Make a copy of the protocol
m_protocols.insert(L3Map_t::value_type(l3p.GetProtocolNumber (), l));
return l;
p->Ref ();
m_protocols.insert(L3Map_t::value_type(p->GetProtocolNumber (), p));
}
L3Protocol*
+1 -8
View File
@@ -49,12 +49,6 @@ public:
void Dispose (void);
/**
* \param node the node on which the returned copy will run.
* \returns a deep copy of this L3 Demux.
*/
L3Demux* Copy(Node *node) const;
/**
* \param context the trace context to use to construct the
* TraceResolver to return
@@ -67,7 +61,6 @@ public:
/**
* \param protocol a template for the protocol to add to this L3 Demux.
* \returns the L3Protocol effectively added.
*
* Invoke Copy on the input template to get a copy of the input
* protocol which can be used on the Node on which this L3 Demux
@@ -75,7 +68,7 @@ public:
* a working L3 Protocol and returned from this method.
* The caller does not get ownership of the returned pointer.
*/
ns3::L3Protocol* Insert(const ns3::L3Protocol& protocol);
void Insert(ns3::L3Protocol * protocol);
/**
* \param protocolNumber number of protocol to lookup
* in this L4 Demux
-2
View File
@@ -48,8 +48,6 @@ public:
virtual void Dispose (void) = 0;
virtual L3Protocol* Copy(Node *node) const = 0;
virtual TraceResolver *CreateTraceResolver (TraceContext const &context) = 0;
/**
* Lower layer calls this method after calling L3Demux::Lookup
+1 -1
View File
@@ -34,8 +34,8 @@ UdpSocket::UdpSocket (Node *node)
m_shutdownRecv (false),
m_connected (false)
{
NS_ASSERT (m_node->GetUdp () != 0);
m_udp = m_node->GetUdp ();
NS_ASSERT (m_udp != 0);
m_node->Ref ();
}
UdpSocket::~UdpSocket ()