This function implements the widely used "djb" hash apparently
posted by Daniel Bernstein to comp.lang.c some time ago. The 32
bit unsigned hash value starts at 5381 and for each byte 'c' in
the string, is updated: hash = hash * 33 + c. This function
uses the signed value of each byte.
It can be passed to g_hash_table_new() as the @hash_func parameter,
when using non-%NULL strings as keys in a #GHashTable.
Note that this function may not be a perfect fit for all use cases.
For example, it produces some hash collisions with strings as short
as 2.
Converts a string to a hash value.
This function implements the widely used "djb" hash apparently posted by Daniel Bernstein to comp.lang.c some time ago. The 32 bit unsigned hash value starts at 5381 and for each byte 'c' in the string, is updated: hash = hash * 33 + c. This function uses the signed value of each byte.
It can be passed to g_hash_table_new() as the @hash_func parameter, when using non-%NULL strings as keys in a #GHashTable.
Note that this function may not be a perfect fit for all use cases. For example, it produces some hash collisions with strings as short as 2.