Really fix itemdef memory leak
authorsapier <Sapier at GMX dot net>
Tue, 9 Apr 2013 18:14:07 +0000 (20:14 +0200)
committerPilzAdam <pilzadam@minetest.net>
Thu, 9 May 2013 15:08:23 +0000 (17:08 +0200)
src/itemdef.cpp

index 05328ea486e4f85118625981330ce5cbedda3d91..d660db77fd850de2f6bc4a78e14fa666d5606b2a 100644 (file)
@@ -226,17 +226,11 @@ class CItemDefManager: public IWritableItemDefManager
 public:
        CItemDefManager()
        {
-               for (std::map<std::string, ItemDefinition*>::iterator iter =
-                               m_item_definitions.begin(); iter != m_item_definitions.end();
-                               iter ++) {
-                       delete iter->second;
-               }
-               m_item_definitions.clear();
+
 #ifndef SERVER
                m_main_thread = get_current_thread_id();
                m_driver = NULL;
 #endif
-       
                clear();
        }
        virtual ~CItemDefManager()
@@ -260,6 +254,12 @@ public:
                }
                m_driver = NULL;
 #endif
+               for (std::map<std::string, ItemDefinition*>::iterator iter =
+                               m_item_definitions.begin(); iter != m_item_definitions.end();
+                               iter ++) {
+                       delete iter->second;
+               }
+               m_item_definitions.clear();
        }
        virtual const ItemDefinition& get(const std::string &name_) const
        {