X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fgit.git;a=blobdiff_plain;f=config.c;h=e7052b39773e4c780b44007c1f06389e581ef82b;hp=743e4570ee38cb6fffe7be7ed06ecdb590481016;hb=da72936f544fec5a335e66432610e4cef4430991;hpb=098e8c6716b8c6abc29b6788acdb3ac8725f835d diff --git a/config.c b/config.c index 743e4570ee..e7052b3977 100644 --- a/config.c +++ b/config.c @@ -1204,7 +1204,7 @@ static int git_default_core_config(const char *var, const char *value, void *cb) default_abbrev = -1; else { int abbrev = git_config_int(var, value); - if (abbrev < minimum_abbrev || abbrev > 40) + if (abbrev < minimum_abbrev || abbrev > the_hash_algo->hexsz) return error(_("abbrev length out of range: %d"), abbrev); default_abbrev = abbrev; } @@ -1856,9 +1856,9 @@ static struct config_set_element *configset_find_element(struct config_set *cs, if (git_config_parse_key(key, &normalized_key, NULL)) return NULL; - hashmap_entry_init(&k, strhash(normalized_key)); + hashmap_entry_init(&k.ent, strhash(normalized_key)); k.key = normalized_key; - found_entry = hashmap_get(&cs->config_hash, &k, NULL); + found_entry = hashmap_get_entry(&cs->config_hash, &k, ent, NULL); free(normalized_key); return found_entry; } @@ -1877,10 +1877,10 @@ static int configset_add_value(struct config_set *cs, const char *key, const cha */ if (!e) { e = xmalloc(sizeof(*e)); - hashmap_entry_init(e, strhash(key)); + hashmap_entry_init(&e->ent, strhash(key)); e->key = xstrdup(key); string_list_init(&e->value_list, 1); - hashmap_add(&cs->config_hash, e); + hashmap_add(&cs->config_hash, &e->ent); } si = string_list_append_nodup(&e->value_list, xstrdup_or_null(value)); @@ -1908,12 +1908,14 @@ static int configset_add_value(struct config_set *cs, const char *key, const cha } static int config_set_element_cmp(const void *unused_cmp_data, - const void *entry, - const void *entry_or_key, + const struct hashmap_entry *eptr, + const struct hashmap_entry *entry_or_key, const void *unused_keydata) { - const struct config_set_element *e1 = entry; - const struct config_set_element *e2 = entry_or_key; + const struct config_set_element *e1, *e2; + + e1 = container_of(eptr, const struct config_set_element, ent); + e2 = container_of(entry_or_key, const struct config_set_element, ent); return strcmp(e1->key, e2->key); } @@ -1934,12 +1936,12 @@ void git_configset_clear(struct config_set *cs) if (!cs->hash_initialized) return; - hashmap_iter_init(&cs->config_hash, &iter); - while ((entry = hashmap_iter_next(&iter))) { + hashmap_for_each_entry(&cs->config_hash, &iter, entry, + ent /* member name */) { free(entry->key); string_list_clear(&entry->value_list, 1); } - hashmap_free(&cs->config_hash, 1); + hashmap_free_entries(&cs->config_hash, struct config_set_element, ent); cs->hash_initialized = 0; free(cs->list.items); cs->list.nr = 0;