Commit 4e02504f by Carlos Martín Nieto

Move config to support the new hash code

The hashes have been copied from the references code

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent 3b4835c2
......@@ -35,18 +35,17 @@
***********************/
static int config_parse(git_config *cfg_file);
static int parse_variable(git_config *cfg, const char *section_name, const char *line);
uint32_t config_table_hash(const void *key)
{
const char *var_name = (char *)key;
return git__hash(key, strlen(var_name), 0x5273eae3);
}
int config_table_haskey(void *object, const void *key)
uint32_t config_table_hash(const void *key, int hash_id)
{
git_config_var *var = (git_config_var *)object;
const char *var_name = (const char *)key;
static uint32_t hash_seeds[GIT_HASHTABLE_HASHES] = {
2147483647,
0x5d20bb23,
0x7daaab3c
};
return (strcmp(var->name, var_name) == 0);
const char *var_name = (const char *)key;
return git__hash(key, strlen(var_name), hash_seeds[hash_id]);
}
int git_config_open(git_config **cfg_out, const char *path)
......@@ -68,7 +67,8 @@ int git_config_open(git_config **cfg_out, const char *path)
goto cleanup;
}
cfg->vars = git_hashtable_alloc(16, config_table_hash, config_table_haskey);
cfg->vars = git_hashtable_alloc(16, config_table_hash,
(git_hash_keyeq_ptr) strcmp);
if (cfg->vars == NULL){
error = GIT_ENOMEM;
goto cleanup;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment