Fixed memory leak in icon loading
o9000 mrovi9000@gmail.com
3 files changed,
7 insertions(+),
5 deletions(-)
M
src/util/cache.c
→
src/util/cache.c
@@ -86,6 +86,8 @@ continue;
if (parse_line(line, &key, &value)) { g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value)); + free(key); + free(value); } } free(line);
M
src/util/common.c
→
src/util/common.c
@@ -73,15 +73,15 @@ fclose(file_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 @@ *value = strdup(a);
g_strstrip(*key); g_strstrip(*value); - return 1; + return TRUE; } void tint_exec(const char *command)
M
src/util/common.h
→
src/util/common.h
@@ -48,7 +48,7 @@ // Parses lines with the format 'key = value' into key and value.
// 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);