diff --git a/src/util/cache.c b/src/util/cache.c index dd6111d..86e07af 100644 --- a/src/util/cache.c +++ b/src/util/cache.c @@ -86,6 +86,8 @@ void load_cache(Cache *cache, const gchar *cache_path) if (parse_line(line, &key, &value)) { g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value)); + free(key); + free(value); } } free(line); diff --git a/src/util/common.c b/src/util/common.c index 4a50e03..bfefee3 100644 --- a/src/util/common.c +++ b/src/util/common.c @@ -73,15 +73,15 @@ void copy_file(const char *path_src, const char *path_dest) fclose(file_src); } -int parse_line(const char *line, char **key, char **value) +gboolean parse_line(const char *line, char **key, char **value) { char *a, *b; /* Skip useless lines */ if ((line[0] == '#') || (line[0] == '\n')) - return 0; + return FALSE; if (!(a = strchr(line, '='))) - return 0; + return FALSE; /* overwrite '=' with '\0' */ a[0] = '\0'; @@ -96,7 +96,7 @@ int parse_line(const char *line, char **key, char **value) g_strstrip(*key); g_strstrip(*value); - return 1; + return TRUE; } void tint_exec(const char *command) diff --git a/src/util/common.h b/src/util/common.h index c2a907f..1bc51bf 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -48,7 +48,7 @@ void copy_file(const char *path_src, const char *path_dest); // Strips key and value. // Values may contain spaces and the equal sign. // Returns 1 if both key and value could be read, zero otherwise. -int parse_line(const char *line, char **key, char **value); +gboolean parse_line(const char *line, char **key, char **value); void extract_values(const char *value, char **value1, char **value2, char **value3);