\brief MARC MAP utilities (hash lookup etc)
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <libxml/parser.h>
#include <yaz/nmem.h>
+#include "jenkins_hash.h"
#include <marchash.h>
-// Jenkins one-at-a-time hash (from pp2 reclists.c, wikipedia)
-static unsigned int hash(const unsigned char *key)
-{
- unsigned int hash = 0;
-
- while (*key)
- {
- hash += *(key++);
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
- return hash;
-}
-
inline void strtrimcat(char *dest, const char *src)
{
const char *in;
struct marcfield *new;
struct marcfield *last;
- slot = hash((const unsigned char *) key) & MARCHASH_MASK;
+ slot = jenkins_hash((const unsigned char *) key) & MARCHASH_MASK;
new = marchash->table[slot];
last = NULL;
if (last)
cur = last->next;
else
- cur = marchash->table[hash((const unsigned char *)key) & MARCHASH_MASK];
+ cur = marchash->table[jenkins_hash((const unsigned char *)key) & MARCHASH_MASK];
while (cur)
{
if (!strcmp(cur->key, key))