diff options
author | kremlin- <ian@kremlin.cc> | 2014-06-20 10:59:38 +0800 |
---|---|---|
committer | kremlin- <ian@kremlin.cc> | 2014-06-20 10:59:38 +0800 |
commit | 7d10ea85785427000ec73b2706260b3a40e20127 (patch) | |
tree | 280adfee06e46cdb84c7c6052bc9589079d25f1d | |
parent | c3b84b0abed4c48ab8ff036081f43a523009c8a9 (diff) | |
download | systembsd-7d10ea85785427000ec73b2706260b3a40e20127.tar systembsd-7d10ea85785427000ec73b2706260b3a40e20127.tar.gz systembsd-7d10ea85785427000ec73b2706260b3a40e20127.tar.bz2 systembsd-7d10ea85785427000ec73b2706260b3a40e20127.tar.lz systembsd-7d10ea85785427000ec73b2706260b3a40e20127.tar.xz systembsd-7d10ea85785427000ec73b2706260b3a40e20127.tar.zst systembsd-7d10ea85785427000ec73b2706260b3a40e20127.zip |
exit func for config, close()s and free()s
-rw-r--r-- | src/config.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c index 5d85346..2b5ec06 100644 --- a/src/config.c +++ b/src/config.c @@ -3,6 +3,7 @@ #include <gio/gio.h> static GKeyFile *config; +static int config_descr; static const gchar *CONFIG_KEYS[] = { "PrettyHostname", @@ -55,7 +56,6 @@ gboolean config_init() { return FALSE; } - int config_descr; config_descr = g_open(config_path, O_CREAT, 644); gchar *posix_hostname; @@ -86,10 +86,22 @@ gboolean config_init() { if(!g_access(config_path, W_OK)) { g_printf("%s\n", "no write permissions for /etc/! exiting.."); return FALSE; - } else if(g_key_file_load_from_file(config, config_path, G_KEY_FILE_KEEP_COMMENTS, NULL)) + } else if(g_key_file_load_from_file(config, config_path, G_KEY_FILE_KEEP_COMMENTS, NULL)) { + config_descr = g_open(config_path, O_RDWR, 644); return TRUE; + } g_printf("could not read config at %s! exiting..", config_path); return FALSE; } } + +void clean_config() { + + if(config) + g_free(config); + + if(config_descr) + g_close(config_descr, NULL); + +} |