diff options
author | Timo Sirainen <cras@irssi.org> | 2003-11-16 16:14:25 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2003-11-16 16:14:25 +0000 |
commit | b5dd35aad5b78ceb3ea1ed12dc057de500c7d5b5 (patch) | |
tree | 58844170b95670a46dd7429511662dc0f1772f82 /src/core | |
parent | d4d2e91f81487821bd243262507a54f8a8b45fec (diff) | |
download | irssi-b5dd35aad5b78ceb3ea1ed12dc057de500c7d5b5.zip |
cleanup
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3138 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/settings.c | 25 | ||||
-rw-r--r-- | src/core/settings.h | 2 |
2 files changed, 14 insertions, 13 deletions
diff --git a/src/core/settings.c b/src/core/settings.c index 62dd5053..e6e0c7d5 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -165,7 +165,7 @@ int settings_get_size(const char *key) static void settings_add(const char *module, const char *section, const char *key, SettingType type, - SettingValue *default_value) + const SettingValue *default_value) { SETTINGS_REC *rec; @@ -188,12 +188,6 @@ static void settings_add(const char *module, const char *section, rec->type = type; rec->default_value = *default_value; - if (type != SETTING_TYPE_INT && - type != SETTING_TYPE_BOOLEAN) { - rec->default_value.v_string = - g_strdup(default_value->v_string); - } - g_hash_table_insert(settings, rec->key, rec); } @@ -205,7 +199,8 @@ void settings_add_str_module(const char *module, const char *section, { SettingValue default_value; - default_value.v_string = (char *) def; + memset(&default_value, 0, sizeof(default_value)); + default_value.v_string = g_strdup(def); settings_add(module, section, key, SETTING_TYPE_STRING, &default_value); } @@ -214,6 +209,7 @@ void settings_add_int_module(const char *module, const char *section, { SettingValue default_value; + memset(&default_value, 0, sizeof(default_value)); default_value.v_int = def; settings_add(module, section, key, SETTING_TYPE_INT, &default_value); } @@ -223,6 +219,7 @@ void settings_add_bool_module(const char *module, const char *section, { SettingValue default_value; + memset(&default_value, 0, sizeof(default_value)); default_value.v_bool = def; settings_add(module, section, key, SETTING_TYPE_BOOLEAN, &default_value); @@ -233,7 +230,8 @@ void settings_add_time_module(const char *module, const char *section, { SettingValue default_value; - default_value.v_string = (char *) def; + memset(&default_value, 0, sizeof(default_value)); + default_value.v_string = g_strdup(def); settings_add(module, section, key, SETTING_TYPE_TIME, &default_value); } @@ -242,7 +240,8 @@ void settings_add_level_module(const char *module, const char *section, { SettingValue default_value; - default_value.v_string = (char *) def; + memset(&default_value, 0, sizeof(default_value)); + default_value.v_string = g_strdup(def); settings_add(module, section, key, SETTING_TYPE_LEVEL, &default_value); } @@ -251,13 +250,15 @@ void settings_add_size_module(const char *module, const char *section, { SettingValue default_value; - default_value.v_string = (char *) def; + memset(&default_value, 0, sizeof(default_value)); + default_value.v_string = g_strdup(def); settings_add(module, section, key, SETTING_TYPE_SIZE, &default_value); } static void settings_destroy(SETTINGS_REC *rec) { - if (rec->type == SETTING_TYPE_STRING) + if (rec->type != SETTING_TYPE_INT && + rec->type != SETTING_TYPE_BOOLEAN) g_free(rec->default_value.v_string); g_free(rec->module); g_free(rec->section); diff --git a/src/core/settings.h b/src/core/settings.h index df4a95ab..8a712dce 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -10,7 +10,7 @@ typedef enum { SETTING_TYPE_SIZE } SettingType; -typedef union { +typedef struct { char *v_string; int v_int; unsigned int v_bool:1; |