Re: [RFC/PATCH v2 1/2] config: Add hashtable for config parsing & retrieval
From: Torsten Bögershausen <hidden>
Date: 2016-06-15 23:01:27
On 2014-06-02 16.47, Tanay Abhra wrote: [] Please see 3 minor remarks inline.
quoted hunk ↗ jump to hunk
--- a/config.c +++ b/config.c@@ -9,6 +9,8 @@ #include "exec_cmd.h" #include "strbuf.h" #include "quote.h" +#include "hashmap.h" +#include "string-list.h" struct config_source { struct config_source *prev;@@ -37,6 +39,112 @@ static struct config_source *cf; static int zlib_compression_seen; +static struct hashmap config_cache; + +struct config_cache_entry { + struct hashmap_entry ent; + char *key; + struct string_list *value_list; +}; + +static int hashmap_is_init = 0;
we don't need the " = 0", as all static data is initialized to 0 (or NULL)
+ +static int config_cache_entry_cmp_icase(const struct config_cache_entry *e1, + const struct config_cache_entry *e2, const char* key)
the * should be aligned to the variable "key": const char *key []
+static void config_cache_set_value(const char *key, const char *value)
+{
+ struct config_cache_entry *e;
+
+ e = config_cache_find_entry(key);
+ if (!e) {
+ e = malloc(sizeof(*e));I think we need xmalloc() here (from wrapper.c)