From 5f6c2cbff7cd778b6487943d62e71ff9e7b04893 Mon Sep 17 00:00:00 2001 From: John Tytgat Date: Sat, 26 Jul 2008 22:29:15 +0000 Subject: - Compiler warning squash - Changed a lineending \n\r -> \n for a couple of files. - More code style conformance. svn path=/trunk/netsurf/; revision=4762 --- utils/hashtable.c | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'utils/hashtable.c') diff --git a/utils/hashtable.c b/utils/hashtable.c index ce4ec3755..6a5bce0ba 100644 --- a/utils/hashtable.c +++ b/utils/hashtable.c @@ -42,6 +42,34 @@ struct hash_table { struct hash_entry **chain; }; +/** + * Hash a string, returning a 32bit value. The hash algorithm used is + * Fowler Noll Vo - a very fast and simple hash, ideal for short strings. + * See http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash for more details. + * + * \param datum The string to hash. + * \param len Pointer to unsigned integer to record datum's length in. + * \return The calculated hash value for the datum. + */ + +static inline unsigned int hash_string_fnv(const char *datum, unsigned int *len) +{ + unsigned int z = 0x01000193; + const char *start = datum; + *len = 0; + + if (datum == NULL) + return 0; + + while (*datum) { + z *= 0x01000193; + z ^= *datum++; + } + *len = datum - start; + + return z; +} + /** * Create a new hash table, and return a context for it. The memory consumption @@ -178,34 +206,6 @@ const char *hash_get(struct hash_table *ht, const char *key) return NULL; } -/** - * Hash a string, returning a 32bit value. The hash algorithm used is - * Fowler Noll Vo - a very fast and simple hash, ideal for short strings. - * See http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash for more details. - * - * \param datum The string to hash. - * \param len Pointer to unsigned integer to record datum's length in. - * \return The calculated hash value for the datum. - */ - -unsigned int hash_string_fnv(const char *datum, unsigned int *len) -{ - unsigned int z = 0x01000193; - const char *start = datum; - *len = 0; - - if (datum == NULL) - return 0; - - while (*datum) { - z *= 0x01000193; - z ^= *datum++; - } - *len = datum - start; - - return z; -} - /** * Iterate through all available hash keys. * -- cgit v1.2.3