From 6e24d52c381f4b46906e368894d72c06d6aef2ed Mon Sep 17 00:00:00 2001 From: paulc Date: Wed, 22 Oct 2008 13:32:25 +0000 Subject: [PATCH] Added static empty instances of ObjList and NamedList. git-svn-id: http://yate.null.ro/svn/yate/trunk@2280 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/NamedList.cpp | 7 +++++++ engine/ObjList.cpp | 7 +++++++ engine/String.cpp | 2 +- yateclass.h | 13 +++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/engine/NamedList.cpp b/engine/NamedList.cpp index 3571184f..eb847907 100644 --- a/engine/NamedList.cpp +++ b/engine/NamedList.cpp @@ -24,6 +24,13 @@ using namespace TelEngine; +static const NamedList s_empty(""); + +const NamedList& NamedList::empty() +{ + return s_empty; +} + NamedList::NamedList(const char* name) : String(name) { diff --git a/engine/ObjList.cpp b/engine/ObjList.cpp index 476f8b87..c4308c69 100644 --- a/engine/ObjList.cpp +++ b/engine/ObjList.cpp @@ -24,6 +24,13 @@ using namespace TelEngine; +static const ObjList s_empty; + +const ObjList& ObjList::empty() +{ + return s_empty; +} + ObjList::ObjList() : m_next(0), m_obj(0), m_delete(true) { diff --git a/engine/String.cpp b/engine/String.cpp index f26fa1b4..c08e1a8e 100644 --- a/engine/String.cpp +++ b/engine/String.cpp @@ -182,7 +182,7 @@ void StringMatchPrivate::fixup() } -static String s_empty; +static const String s_empty; const String& String::empty() { diff --git a/yateclass.h b/yateclass.h index f7fe4779..2043d24c 100644 --- a/yateclass.h +++ b/yateclass.h @@ -1113,6 +1113,12 @@ public: inline void setDelete(bool autodelete) { m_delete = autodelete; } + /** + * A static empty object list + * @return Reference to a static empty list + */ + static const ObjList& empty(); + private: ObjList* m_next; GenObject* m_obj; @@ -1292,6 +1298,7 @@ public: /** * A static null String + * @return Reference to a static empty String */ static const String& empty(); @@ -3180,6 +3187,12 @@ public: */ int replaceParams(String& str, bool sqlEsc = false, char extraEsc = 0) const; + /** + * A static empty named list + * @return Reference to a static empty named list + */ + static const NamedList& empty(); + private: NamedList(); // no default constructor please NamedList& operator=(const NamedList& value); // no assignment please