diff --git a/src/object/singleton.h b/src/object/singleton.h index 2a97c6609..667f71f9b 100644 --- a/src/object/singleton.h +++ b/src/object/singleton.h @@ -31,31 +31,17 @@ public: virtual ~Singleton () = default; static T *getInstance () { - if (!mInstance) { - mInstance = new T(); - static SingletonDeleter deleter; - } - return mInstance; + static T instance; + return &instance; } protected: explicit Singleton (ObjectPrivate &p) : Object(p) {} private: - struct SingletonDeleter { - ~SingletonDeleter () { - delete mInstance; - } - }; - - static T *mInstance; - L_DISABLE_COPY(Singleton); }; -template -T *Singleton::mInstance = nullptr; - LINPHONE_END_NAMESPACE #endif // ifndef _SINGLETON_H_