diff options
author | Timo Sirainen <cras@irssi.org> | 2000-05-10 13:57:42 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-05-10 13:57:42 +0000 |
commit | bb4d7566c29162976f1d47ce51c1ffd1ce2041d6 (patch) | |
tree | 796489749de7f4b7bc5db0376f800df0ad434732 /src/lib-config/get.c | |
parent | afc4fbc2238f9b76df9e704446ec9be64ee2f57b (diff) | |
download | irssi-bb4d7566c29162976f1d47ce51c1ffd1ce2041d6.zip |
iconfig's caching was a bit buggy - it didn't notice if some config node was
removed.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@213 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/lib-config/get.c')
-rw-r--r-- | src/lib-config/get.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib-config/get.c b/src/lib-config/get.c index 8ac3e667..07a328ce 100644 --- a/src/lib-config/get.c +++ b/src/lib-config/get.c @@ -70,7 +70,7 @@ CONFIG_NODE *config_node_section(CONFIG_NODE *parent, const char *key, int new_t CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int create) { CONFIG_NODE *node; - char **list, **tmp; + char **list, **tmp, *str; int is_list, new_type; g_return_val_if_fail(rec != NULL, NULL); @@ -96,7 +96,9 @@ CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int crea g_strfreev(list); /* save to cache */ - g_hash_table_insert(rec->cache, g_strdup(section), node); + str = g_strdup(section); + g_hash_table_insert(rec->cache, str, node); + g_hash_table_insert(rec->cache_nodes, node, str); return node; } @@ -120,10 +122,12 @@ char *config_get_str(CONFIG_REC *rec, const char *section, const char *key, cons config_node_find(parent, key); /* save to cache */ - if (node != NULL) + if (node == NULL) + g_free(path); + else { g_hash_table_insert(rec->cache, path, node); - else - g_free(path); + g_hash_table_insert(rec->cache_nodes, node, path); + } } return (node == NULL || !has_node_value(node)) ? (char *) def : node->value; |