diff --git a/src/core/names-test-suite.cc b/src/core/names-test-suite.cc index e754e7cb2..e1ed9c6ac 100644 --- a/src/core/names-test-suite.cc +++ b/src/core/names-test-suite.cc @@ -71,6 +71,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; BasicAddTestCase::BasicAddTestCase () @@ -82,6 +83,12 @@ BasicAddTestCase::~BasicAddTestCase () { } +void +BasicAddTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool BasicAddTestCase::DoRun (void) { @@ -131,6 +138,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; StringContextAddTestCase::StringContextAddTestCase () @@ -143,6 +151,12 @@ StringContextAddTestCase::~StringContextAddTestCase () { } +void +StringContextAddTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool StringContextAddTestCase::DoRun (void) { @@ -189,6 +203,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; FullyQualifiedAddTestCase::FullyQualifiedAddTestCase () @@ -201,6 +216,12 @@ FullyQualifiedAddTestCase::~FullyQualifiedAddTestCase () { } +void +FullyQualifiedAddTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool FullyQualifiedAddTestCase::DoRun (void) { @@ -250,6 +271,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; RelativeAddTestCase::RelativeAddTestCase () @@ -262,6 +284,12 @@ RelativeAddTestCase::~RelativeAddTestCase () { } +void +RelativeAddTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool RelativeAddTestCase::DoRun (void) { @@ -311,6 +339,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; BasicRenameTestCase::BasicRenameTestCase () @@ -322,6 +351,12 @@ BasicRenameTestCase::~BasicRenameTestCase () { } +void +BasicRenameTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool BasicRenameTestCase::DoRun (void) { @@ -366,6 +401,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; StringContextRenameTestCase::StringContextRenameTestCase () @@ -377,6 +413,12 @@ StringContextRenameTestCase::~StringContextRenameTestCase () { } +void +StringContextRenameTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool StringContextRenameTestCase::DoRun (void) { @@ -421,6 +463,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; FullyQualifiedRenameTestCase::FullyQualifiedRenameTestCase () @@ -432,6 +475,12 @@ FullyQualifiedRenameTestCase::~FullyQualifiedRenameTestCase () { } +void +FullyQualifiedRenameTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool FullyQualifiedRenameTestCase::DoRun (void) { @@ -476,6 +525,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; RelativeRenameTestCase::RelativeRenameTestCase () @@ -487,6 +537,12 @@ RelativeRenameTestCase::~RelativeRenameTestCase () { } +void +RelativeRenameTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool RelativeRenameTestCase::DoRun (void) { @@ -531,6 +587,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; FindPathTestCase::FindPathTestCase () @@ -542,6 +599,12 @@ FindPathTestCase::~FindPathTestCase () { } +void +FindPathTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool FindPathTestCase::DoRun (void) { @@ -580,6 +643,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; BasicFindTestCase::BasicFindTestCase () @@ -591,6 +655,12 @@ BasicFindTestCase::~BasicFindTestCase () { } +void +BasicFindTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool BasicFindTestCase::DoRun (void) { @@ -637,6 +707,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; StringContextFindTestCase::StringContextFindTestCase () @@ -648,6 +719,12 @@ StringContextFindTestCase::~StringContextFindTestCase () { } +void +StringContextFindTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool StringContextFindTestCase::DoRun (void) { @@ -694,6 +771,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; FullyQualifiedFindTestCase::FullyQualifiedFindTestCase () @@ -705,6 +783,12 @@ FullyQualifiedFindTestCase::~FullyQualifiedFindTestCase () { } +void +FullyQualifiedFindTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool FullyQualifiedFindTestCase::DoRun (void) { @@ -751,6 +835,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; RelativeFindTestCase::RelativeFindTestCase () @@ -762,6 +847,12 @@ RelativeFindTestCase::~RelativeFindTestCase () { } +void +RelativeFindTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool RelativeFindTestCase::DoRun (void) { @@ -806,6 +897,7 @@ public: private: virtual bool DoRun (void); + virtual void DoTeardown (void); }; AlternateFindTestCase::AlternateFindTestCase () @@ -817,6 +909,12 @@ AlternateFindTestCase::~AlternateFindTestCase () { } +void +AlternateFindTestCase::DoTeardown (void) +{ + Names::Clear (); +} + bool AlternateFindTestCase::DoRun (void) { diff --git a/src/core/names.cc b/src/core/names.cc index 3b4ca3493..0dd1aff8b 100644 --- a/src/core/names.cc +++ b/src/core/names.cc @@ -93,6 +93,8 @@ public: std::string FindName (Ptr object); std::string FindPath (Ptr object); + void Clear (void); + Ptr Find (std::string name); Ptr Find (std::string path, std::string name); Ptr Find (Ptr context, std::string name); @@ -127,7 +129,12 @@ NamesPriv::NamesPriv () NamesPriv::~NamesPriv () { NS_LOG_FUNCTION_NOARGS (); + Clear (); +} +void +NamesPriv::Clear (void) +{ // // Every name is associated with an object in the object map, so freeing the // NameNodes in this map will free all of the memory allocated for the NameNodes @@ -138,9 +145,12 @@ NamesPriv::~NamesPriv () i->second = 0; } + m_objectMap.clear (); + m_root.m_parent = 0; m_root.m_name = ""; m_root.m_object = 0; + m_root.m_nameMap.clear (); } bool @@ -647,6 +657,12 @@ Names::FindPath (Ptr object) return NamesPriv::Get ()->FindPath (object); } +void +Names::Clear (void) +{ + return NamesPriv::Get ()->Clear (); +} + Ptr Names::FindInternal (std::string name) { diff --git a/src/core/names.h b/src/core/names.h index 533e0c262..5bebb091e 100644 --- a/src/core/names.h +++ b/src/core/names.h @@ -277,6 +277,12 @@ public: */ static std::string FindPath (Ptr object); + /** + * Clear the list of objects associated with names. + */ + + static void Clear (void); + /** * Given a name path string, look to see if there's an object in the system * with that associated to it. If there is, do a GetObject on the resulting