diff --git a/src/core/config.cc b/src/core/config.cc index d8fbfb61d..1f30e03ff 100644 --- a/src/core/config.cc +++ b/src/core/config.cc @@ -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; } diff --git a/src/core/object-names.cc b/src/core/object-names.cc index b27cb61c4..e42c5122d 100644 --- a/src/core/object-names.cc +++ b/src/core/object-names.cc @@ -17,12 +17,12 @@ */ #include -#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 FindObjectFromShortName (Ptr context, std::string name); static NamesPriv *Get (void); - + static void Delete (void); private: static NamesPriv **DoGet (void); - static void Delete (void); NameNode *IsNamed (Ptr); 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) { diff --git a/src/core/object-names.h b/src/core/object-names.h index d034e3d55..b53e5e955 100644 --- a/src/core/object-names.h +++ b/src/core/object-names.h @@ -171,8 +171,14 @@ public: template static Ptr FindObjectFromShortName (Ptr 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 *