summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/hashtable.c56
-rw-r--r--utils/hashtable.h1
2 files changed, 28 insertions, 29 deletions
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
@@ -179,34 +207,6 @@ const char *hash_get(struct hash_table *ht, const char *key)
}
/**
- * 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.
*
* \param ht The hash table context to iterate.
diff --git a/utils/hashtable.h b/utils/hashtable.h
index 2c698b0b3..432ccfe2a 100644
--- a/utils/hashtable.h
+++ b/utils/hashtable.h
@@ -30,7 +30,6 @@ struct hash_table *hash_create(unsigned int chains);
void hash_destroy(struct hash_table *ht);
bool hash_add(struct hash_table *ht, const char *key, const char *value);
const char *hash_get(struct hash_table *ht, const char *key);
-inline unsigned int hash_string_fnv(const char *datum, unsigned int *len);
const char *hash_iterate(struct hash_table *ht, unsigned int *c1,
unsigned int **c2);