Code cleanup
This commit is contained in:
parent
375c364345
commit
1556118b7e
48
src/hash.c
48
src/hash.c
|
@ -72,30 +72,6 @@ struct _Hash
|
|||
};
|
||||
|
||||
|
||||
/* functions */
|
||||
/* hash_func_string */
|
||||
unsigned int hash_func_string(void const * key)
|
||||
{
|
||||
String const * str = key;
|
||||
size_t i;
|
||||
unsigned int hash = 0;
|
||||
|
||||
for(i = 0; i < sizeof(hash) && str[i] != '\0'; i++)
|
||||
hash |= str[i] << (i << 3);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
/* hash_compare_string */
|
||||
int hash_compare_string(void const * value1, void const * value2)
|
||||
{
|
||||
String const * str1 = value1;
|
||||
String const * str2 = value2;
|
||||
|
||||
return string_compare(str1, str2);
|
||||
}
|
||||
|
||||
|
||||
/* public */
|
||||
/* functions */
|
||||
/* hash_new */
|
||||
|
@ -129,6 +105,30 @@ void hash_delete(Hash * hash)
|
|||
}
|
||||
|
||||
|
||||
/* helpers */
|
||||
/* hash_func_string */
|
||||
unsigned int hash_func_string(void const * key)
|
||||
{
|
||||
String const * str = key;
|
||||
size_t i;
|
||||
unsigned int hash = 0;
|
||||
|
||||
for(i = 0; i < sizeof(hash) && str[i] != '\0'; i++)
|
||||
hash |= str[i] << (i << 3);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
/* hash_compare_string */
|
||||
int hash_compare_string(void const * value1, void const * value2)
|
||||
{
|
||||
String const * str1 = value1;
|
||||
String const * str2 = value2;
|
||||
|
||||
return string_compare(str1, str2);
|
||||
}
|
||||
|
||||
|
||||
/* accessors */
|
||||
/* hash_get */
|
||||
void * hash_get(Hash * hash, void const * key)
|
||||
|
|
Loading…
Reference in New Issue
Block a user