fix(xresources): Deallocate memory

This commit is contained in:
Michael Carlberg 2016-12-09 22:54:30 +01:00
parent 83f7d2ce91
commit a33c15b3ad
2 changed files with 14 additions and 1 deletions

View File

@ -12,6 +12,7 @@ class xresource_manager {
static make_type make();
explicit xresource_manager();
~xresource_manager();
string get_string(string name, string fallback = "") const;
float get_float(string name, float fallback = 0.0f) const;
@ -21,7 +22,7 @@ class xresource_manager {
string load_value(const string& key, const string& res_type, size_t n) const;
private:
char* m_manager = nullptr;
char* m_manager{nullptr};
XrmDatabase m_db;
};

View File

@ -33,6 +33,18 @@ xresource_manager::xresource_manager() {
}
}
/**
* Deconstruct instance
*/
xresource_manager::~xresource_manager() {
if (m_db != nullptr) {
XrmDestroyDatabase(m_db);
}
if (m_manager != nullptr) {
XFree(m_manager);
}
}
/**
* Get string value from the X resource db
*/