Fix a memleak pointed by @Zeno- in MeshUpdateQueue
[oweals/minetest.git] / src / settings.h
index c6c044779444df554ee3f227e9efe1bbd98863b1..8c4f6e559e05cfedc9f0c21953d947a6b9f80c69 100644 (file)
@@ -74,30 +74,29 @@ struct ValueSpec {
 };
 
 struct SettingsEntry {
-       SettingsEntry()
-       {
-               group    = NULL;
-               is_group = false;
-       }
-
-       SettingsEntry(const std::string &value_)
-       {
-               value    = value_;
-               group    = NULL;
-               is_group = false;
-       }
-
-       SettingsEntry(Settings *group_)
-       {
-               group    = group_;
-               is_group = true;
-       }
+       SettingsEntry() :
+               group(NULL),
+               is_group(false)
+       {}
+
+       SettingsEntry(const std::string &value_) :
+               value(value_),
+               group(NULL),
+               is_group(false)
+       {}
+
+       SettingsEntry(Settings *group_) :
+               group(group_),
+               is_group(true)
+       {}
 
        std::string value;
        Settings *group;
        bool is_group;
 };
 
+typedef UNORDERED_MAP<std::string, SettingsEntry> SettingEntries;
+
 class Settings {
 public:
        Settings() {}
@@ -127,8 +126,6 @@ public:
 
        static bool checkNameValid(const std::string &name);
        static bool checkValueValid(const std::string &value);
-       static std::string sanitizeName(const std::string &name);
-       static std::string sanitizeValue(const std::string &value);
        static std::string getMultiline(std::istream &is, size_t *num_lines=NULL);
        static void printEntry(std::ostream &os, const std::string &name,
                const SettingsEntry &entry, u32 tab_depth=0);
@@ -139,7 +136,7 @@ public:
 
        const SettingsEntry &getEntry(const std::string &name) const;
        Settings *getGroup(const std::string &name) const;
-       std::string get(const std::string &name) const;
+       const std::string &get(const std::string &name) const;
        bool getBool(const std::string &name) const;
        u16 getU16(const std::string &name) const;
        s16 getS16(const std::string &name) const;
@@ -231,8 +228,8 @@ private:
 
        void doCallbacks(const std::string &name) const;
 
-       std::map<std::string, SettingsEntry> m_settings;
-       std::map<std::string, SettingsEntry> m_defaults;
+       SettingEntries m_settings;
+       SettingEntries m_defaults;
 
        SettingsCallbackMap m_callbacks;