--- a/src/core/names.cc Tue Feb 10 11:28:40 2009 -0800
+++ b/src/core/names.cc Wed Feb 11 22:37:00 2009 -0800
@@ -101,7 +101,7 @@
static NamesPriv *Get (void);
static void Delete (void);
private:
- static NamesPriv **DoGet (void);
+ static NamesPriv **DoGet (bool doCreate);
NameNode *IsNamed (Ptr<Object>);
bool IsDuplicateName (NameNode *node, std::string name);
@@ -113,15 +113,15 @@
NamesPriv *
NamesPriv::Get (void)
{
- return *(DoGet ());
+ return *(DoGet (true));
}
NamesPriv **
-NamesPriv::DoGet (void)
+NamesPriv::DoGet (bool doCreate)
{
static NamesPriv *ptr = 0;
- if (ptr == 0)
+ if (ptr == 0 && doCreate)
{
ptr = new NamesPriv;
Simulator::ScheduleDestroy (&NamesPriv::Delete);
@@ -135,7 +135,7 @@
{
NS_LOG_FUNCTION_NOARGS ();
- NamesPriv **ptr = DoGet ();
+ NamesPriv **ptr = DoGet (false);
delete *ptr;
*ptr = 0;
}
@@ -966,14 +966,7 @@
result = Names::Rename ("/Names/RouterX", "RouterY");
NS_TEST_ASSERT_EQUAL (result, false);
- //
- // Run the simulator and destroy it to get the Destroy method called on the
- // private implementation object. We depend on seeing a valgrind-clean run of
- // the unit tests to really determine if the clean up was really successful.
- //
- Simulator::Run ();
- Simulator::Destroy ();
-
+ Names::Delete ();
return true;
}