From 64b978b77ac4f84a6421f7c665c1dc3c20067e43 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 3 Nov 2020 14:47:01 +0800 Subject: [PATCH] Fix memory release --- nel/include/nel/misc/factory.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/nel/include/nel/misc/factory.h b/nel/include/nel/misc/factory.h index b1c22a668..82da7ce7d 100644 --- a/nel/include/nel/misc/factory.h +++ b/nel/include/nel/misc/factory.h @@ -58,12 +58,8 @@ public: static CFactory &instance() { // Singleton instance pointer. - static CFactory *instance = NULL; - if (!instance) - { - instance = new CFactory(); - } - return *instance; + static CFactory instance; + return instance; } /** Register a factorable object in the factory. @@ -185,12 +181,8 @@ public: /// Get the singleton instance reference. static CFactoryIndirect &instance() { - static CFactoryIndirect *instance = NULL; - if (!instance) - { - instance = new CFactoryIndirect(); - } - return *instance; + static CFactoryIndirect instance; + return instance; } void registerClass(const KeyType &key, IFactoryIndirectRegister *factoryRegister)