add NamesPriv cleanup for code that doesn't use simulator -- for valgrind-clean runs

This commit is contained in:
Craig Dowell
2009-01-20 22:42:11 -08:00
parent c37f4c2169
commit e1a8e44e43
3 changed files with 29 additions and 9 deletions

View File

@@ -931,7 +931,12 @@ ConfigTest::RunTests (void)
d1->SetAttribute ("Source", IntegerValue (-4));
NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
//
// The Config system is intertwined with the Names system. In the process
// of parsing the paths above, we also created a NamesPriv singleton. In
// order to get a valgrind-clean run we need to clean up that singleton.
//
Names::Delete ();
return result;
}

View File

@@ -17,12 +17,12 @@
*/
#include <map>
#include "ns3/object.h"
#include "ns3/log.h"
#include "ns3/assert.h"
#include "ns3/abort.h"
#include "ns3/simulator.h"
#include "object.h"
#include "log.h"
#include "assert.h"
#include "abort.h"
#include "object-names.h"
#include "ns3/simulator.h"
namespace ns3 {
@@ -92,10 +92,9 @@ public:
Ptr<Object> FindObjectFromShortName (Ptr<Object> context, std::string name);
static NamesPriv *Get (void);
static void Delete (void);
private:
static NamesPriv **DoGet (void);
static void Delete (void);
NameNode *IsNamed (Ptr<Object>);
bool IsDuplicateName (NameNode *node, std::string name);
@@ -156,6 +155,10 @@ NamesPriv::~NamesPriv ()
delete i->second;
i->second = 0;
}
m_root.m_parent = 0;
m_root.m_name = "";
m_root.m_object = 0;
}
bool
@@ -444,6 +447,12 @@ NamesPriv::IsDuplicateName (NameNode *node, std::string name)
}
}
void
Names::Delete (void)
{
NamesPriv::Delete ();
}
bool
Names::Add (std::string name, Ptr<Object> object)
{

View File

@@ -171,8 +171,14 @@ public:
template <typename T>
static Ptr<T> FindObjectFromShortName (Ptr<Object> context, std::string name);
private:
/**
* Clean up all of the data structures of the implementation and delete the
* underlying singleton. Used to get valgrind-clean runs if the simulator
* is not run. Normally singleton cleanup is scheduled on Simulator::Destroy.
*/
static void Delete (void);
private:
/**
* \internal
*