add NamesPriv cleanup for code that doesn't use simulator -- for valgrind-clean runs
1.1 --- a/src/core/config.cc Tue Jan 20 21:55:04 2009 -0800
1.2 +++ b/src/core/config.cc Tue Jan 20 22:42:11 2009 -0800
1.3 @@ -931,7 +931,12 @@
1.4 d1->SetAttribute ("Source", IntegerValue (-4));
1.5 NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
1.6
1.7 -
1.8 + //
1.9 + // The Config system is intertwined with the Names system. In the process
1.10 + // of parsing the paths above, we also created a NamesPriv singleton. In
1.11 + // order to get a valgrind-clean run we need to clean up that singleton.
1.12 + //
1.13 + Names::Delete ();
1.14
1.15 return result;
1.16 }
2.1 --- a/src/core/object-names.cc Tue Jan 20 21:55:04 2009 -0800
2.2 +++ b/src/core/object-names.cc Tue Jan 20 22:42:11 2009 -0800
2.3 @@ -17,12 +17,12 @@
2.4 */
2.5
2.6 #include <map>
2.7 -#include "ns3/object.h"
2.8 -#include "ns3/log.h"
2.9 -#include "ns3/assert.h"
2.10 -#include "ns3/abort.h"
2.11 +#include "object.h"
2.12 +#include "log.h"
2.13 +#include "assert.h"
2.14 +#include "abort.h"
2.15 +#include "object-names.h"
2.16 #include "ns3/simulator.h"
2.17 -#include "object-names.h"
2.18
2.19 namespace ns3 {
2.20
2.21 @@ -92,10 +92,9 @@
2.22 Ptr<Object> FindObjectFromShortName (Ptr<Object> context, std::string name);
2.23
2.24 static NamesPriv *Get (void);
2.25 -
2.26 + static void Delete (void);
2.27 private:
2.28 static NamesPriv **DoGet (void);
2.29 - static void Delete (void);
2.30
2.31 NameNode *IsNamed (Ptr<Object>);
2.32 bool IsDuplicateName (NameNode *node, std::string name);
2.33 @@ -156,6 +155,10 @@
2.34 delete i->second;
2.35 i->second = 0;
2.36 }
2.37 +
2.38 + m_root.m_parent = 0;
2.39 + m_root.m_name = "";
2.40 + m_root.m_object = 0;
2.41 }
2.42
2.43 bool
2.44 @@ -444,6 +447,12 @@
2.45 }
2.46 }
2.47
2.48 +void
2.49 +Names::Delete (void)
2.50 +{
2.51 + NamesPriv::Delete ();
2.52 +}
2.53 +
2.54 bool
2.55 Names::Add (std::string name, Ptr<Object> object)
2.56 {
3.1 --- a/src/core/object-names.h Tue Jan 20 21:55:04 2009 -0800
3.2 +++ b/src/core/object-names.h Tue Jan 20 22:42:11 2009 -0800
3.3 @@ -171,8 +171,14 @@
3.4 template <typename T>
3.5 static Ptr<T> FindObjectFromShortName (Ptr<Object> context, std::string name);
3.6
3.7 + /**
3.8 + * Clean up all of the data structures of the implementation and delete the
3.9 + * underlying singleton. Used to get valgrind-clean runs if the simulator
3.10 + * is not run. Normally singleton cleanup is scheduled on Simulator::Destroy.
3.11 + */
3.12 + static void Delete (void);
3.13 +
3.14 private:
3.15 -
3.16 /**
3.17 * \internal
3.18 *