diff options
author | James Booth <boothj5@gmail.com> | 2014-06-18 00:32:36 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-06-18 00:32:36 +0100 |
commit | 7344d3b8987f6e2edb12a3861a07006e27fb80e5 (patch) | |
tree | e6a037f4c4c4b4083731c6f73adff66e9db6cb35 /src/config | |
parent | 79ddf1048486d1a77a1aee9b8152c8ffb25d8a11 (diff) | |
download | profani-tty-7344d3b8987f6e2edb12a3861a07006e27fb80e5.tar.gz |
Added deallocation function for string prefs, added otr policy enum
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/preferences.c | 20 | ||||
-rw-r--r-- | src/config/preferences.h | 1 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c index 335915aa..49203bfb 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -164,20 +164,30 @@ prefs_get_string(preference_t pref) const char *key = _get_key(pref); char *def = _get_default_string(pref); - if (!g_key_file_has_key(prefs, group, key, NULL)) { - return def; - } - char *result = g_key_file_get_string(prefs, group, key, NULL); if (result == NULL) { - return strdup(def); + if (def != NULL) { + return strdup(def); + } else { + return NULL; + } } else { return result; } } void +prefs_free_string(char *pref) +{ + if (pref != NULL) { + free(pref); + } + pref = NULL; +} + + +void prefs_set_string(preference_t pref, char *value) { const char *group = _get_group(pref); diff --git a/src/config/preferences.h b/src/config/preferences.h index 3de860d2..cdb0f2de 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -115,6 +115,7 @@ void prefs_free_aliases(GList *aliases); gboolean prefs_get_boolean(preference_t pref); void prefs_set_boolean(preference_t pref, gboolean value); char * prefs_get_string(preference_t pref); +void prefs_free_string(char *pref); void prefs_set_string(preference_t pref, char *value); #endif |