PacketBB: Tidy up some memory leaks.
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/ipv6-address.h"
|
||||
#include "packetbb.h"
|
||||
#include "ns3/packetbb.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
@@ -34,7 +34,7 @@ class PbbTestCase : public TestCase
|
||||
public:
|
||||
PbbTestCase (std::string name, Ptr<PbbPacket> packet,
|
||||
uint8_t * buffer, uint32_t size);
|
||||
virtual ~PbbTestCase ();
|
||||
virtual ~PbbTestCase (void);
|
||||
|
||||
protected:
|
||||
virtual bool DoRun (void);
|
||||
@@ -59,6 +59,7 @@ PbbTestCase::PbbTestCase (std::string name, Ptr<PbbPacket> packet,
|
||||
|
||||
PbbTestCase::~PbbTestCase (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -58,6 +58,16 @@ namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (PbbPacket);
|
||||
|
||||
PbbTlvBlock::PbbTlvBlock (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PbbTlvBlock::~PbbTlvBlock (void)
|
||||
{
|
||||
Clear ();
|
||||
}
|
||||
|
||||
PbbTlvBlock::Iterator
|
||||
PbbTlvBlock::Begin (void)
|
||||
{
|
||||
@@ -151,6 +161,10 @@ PbbTlvBlock::Erase (PbbTlvBlock::Iterator first, PbbTlvBlock::Iterator last)
|
||||
void
|
||||
PbbTlvBlock::Clear (void)
|
||||
{
|
||||
for (Iterator iter = Begin (); iter != End (); iter++)
|
||||
{
|
||||
*iter = 0;
|
||||
}
|
||||
m_tlvList.clear ();
|
||||
}
|
||||
|
||||
@@ -262,6 +276,16 @@ PbbTlvBlock::operator!= (const PbbTlvBlock &other) const
|
||||
|
||||
/* End PbbTlvBlock class */
|
||||
|
||||
PbbAddressTlvBlock::PbbAddressTlvBlock (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PbbAddressTlvBlock::~PbbAddressTlvBlock (void)
|
||||
{
|
||||
Clear ();
|
||||
}
|
||||
|
||||
PbbAddressTlvBlock::Iterator
|
||||
PbbAddressTlvBlock::Begin (void)
|
||||
{
|
||||
@@ -355,6 +379,10 @@ PbbAddressTlvBlock::Erase (PbbAddressTlvBlock::Iterator first, PbbAddressTlvBloc
|
||||
void
|
||||
PbbAddressTlvBlock::Clear (void)
|
||||
{
|
||||
for (Iterator iter = Begin (); iter != End (); iter++)
|
||||
{
|
||||
*iter = 0;
|
||||
}
|
||||
m_tlvList.clear ();
|
||||
}
|
||||
|
||||
@@ -474,6 +502,11 @@ PbbPacket::PbbPacket (void)
|
||||
m_hasseqnum = false;
|
||||
}
|
||||
|
||||
PbbPacket::~PbbPacket (void)
|
||||
{
|
||||
MessageClear ();
|
||||
}
|
||||
|
||||
uint8_t
|
||||
PbbPacket::GetVersion (void) const
|
||||
{
|
||||
@@ -706,6 +739,10 @@ PbbPacket::Erase (PbbPacket::MessageIterator first,
|
||||
void
|
||||
PbbPacket::MessageClear (void)
|
||||
{
|
||||
for (MessageIterator iter = MessageBegin (); iter != MessageEnd (); iter++)
|
||||
{
|
||||
*iter = 0;
|
||||
}
|
||||
m_messageList.clear ();
|
||||
}
|
||||
|
||||
@@ -921,6 +958,7 @@ PbbMessage::PbbMessage ()
|
||||
|
||||
PbbMessage::~PbbMessage ()
|
||||
{
|
||||
AddressBlockClear ();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1122,7 +1160,7 @@ PbbMessage::TlvErase (PbbMessage::TlvIterator first, PbbMessage::TlvIterator las
|
||||
void
|
||||
PbbMessage::TlvClear (void)
|
||||
{
|
||||
return m_tlvList.Clear();
|
||||
m_tlvList.Clear();
|
||||
}
|
||||
|
||||
/* Manipulating Address Block and Address TLV pairs */
|
||||
@@ -1227,6 +1265,12 @@ PbbMessage::AddressBlockErase (PbbMessage::AddressBlockIterator first,
|
||||
void
|
||||
PbbMessage::AddressBlockClear (void)
|
||||
{
|
||||
for (AddressBlockIterator iter = AddressBlockBegin ();
|
||||
iter != AddressBlockEnd ();
|
||||
iter++)
|
||||
{
|
||||
*iter = 0;
|
||||
}
|
||||
return m_addressBlockList.clear();
|
||||
}
|
||||
|
||||
@@ -1956,7 +2000,7 @@ PbbAddressBlock::TlvErase (PbbAddressBlock::TlvIterator first,
|
||||
void
|
||||
PbbAddressBlock::TlvClear (void)
|
||||
{
|
||||
return m_addressTlvList.Clear();
|
||||
m_addressTlvList.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2412,6 +2456,11 @@ PbbTlv::PbbTlv (void)
|
||||
m_hasValue = false;
|
||||
}
|
||||
|
||||
PbbTlv::~PbbTlv (void)
|
||||
{
|
||||
m_value.RemoveAtEnd (m_value.GetSize ());
|
||||
}
|
||||
|
||||
void
|
||||
PbbTlv::SetType (uint8_t type)
|
||||
{
|
||||
@@ -2506,10 +2555,9 @@ PbbTlv::SetValue (Buffer start)
|
||||
void
|
||||
PbbTlv::SetValue (const uint8_t * buffer, uint32_t size)
|
||||
{
|
||||
Buffer value;
|
||||
value.AddAtStart (size);
|
||||
value.Begin ().Write (buffer, size);
|
||||
SetValue (value);
|
||||
m_hasValue = true;
|
||||
m_value.AddAtStart (size);
|
||||
m_value.Begin ().Write (buffer, size);
|
||||
}
|
||||
|
||||
Buffer
|
||||
|
||||
@@ -57,6 +57,9 @@ public:
|
||||
typedef std::list< Ptr<PbbTlv> >::iterator Iterator;
|
||||
typedef std::list< Ptr<PbbTlv> >::const_iterator ConstIterator;
|
||||
|
||||
PbbTlvBlock (void);
|
||||
~PbbTlvBlock (void);
|
||||
|
||||
/**
|
||||
* \return an iterator to the first TLV in this block.
|
||||
*/
|
||||
@@ -206,6 +209,9 @@ public:
|
||||
typedef std::list< Ptr<PbbAddressTlv> >::iterator Iterator;
|
||||
typedef std::list< Ptr<PbbAddressTlv> >::const_iterator ConstIterator;
|
||||
|
||||
PbbAddressTlvBlock (void);
|
||||
~PbbAddressTlvBlock (void);
|
||||
|
||||
/**
|
||||
* \return an iterator to the first Address TLV in this block.
|
||||
*/
|
||||
@@ -363,6 +369,7 @@ public:
|
||||
typedef std::list< Ptr<PbbMessage> >::const_iterator ConstMessageIterator;
|
||||
|
||||
PbbPacket (void);
|
||||
~PbbPacket (void);
|
||||
|
||||
/**
|
||||
* \return the version of PacketBB that constructed this packet.
|
||||
@@ -1517,6 +1524,7 @@ class PbbTlv
|
||||
{
|
||||
public:
|
||||
PbbTlv (void);
|
||||
~PbbTlv (void);
|
||||
|
||||
/**
|
||||
* \brief Sets the type of this TLV.
|
||||
|
||||
Reference in New Issue
Block a user