X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fhash.c;h=f2d99e3a8f31204d9a93d48cc1208695bff78713;hb=207dcaa849d7c1d5090f198e9c86f9bfc484a89e;hp=bc5933a2b5813521dbe51e9cda5eb117590fcc72;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp-builds.git
diff --git a/src/libpspp/hash.c b/src/libpspp/hash.c
index bc5933a2..f2d99e3a 100644
--- a/src/libpspp/hash.c
+++ b/src/libpspp/hash.c
@@ -1,5 +1,5 @@
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,21 +15,20 @@
along with this program. If not, see . */
#include
-#include
-#include "hash.h"
-#include "message.h"
+
#include
-#include
#include
#include
#include
+
#include "array.h"
-#include "alloc.h"
#include "compiler.h"
+#include "hash.h"
#include "misc.h"
-#include "str.h"
#include "pool.h"
+#include "str.h"
+#include "xalloc.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
@@ -70,74 +69,6 @@ next_power_of_2 (size_t x)
}
}
-/* Fowler-Noll-Vo hash constants, for 32-bit word sizes. */
-#define FNV_32_PRIME 16777619u
-#define FNV_32_BASIS 2166136261u
-
-/* Fowler-Noll-Vo 32-bit hash, for bytes. */
-unsigned
-hsh_hash_bytes (const void *buf_, size_t size)
-{
- const unsigned char *buf = (const unsigned char *) buf_;
- unsigned hash;
-
- assert (buf != NULL);
-
- hash = FNV_32_BASIS;
- while (size-- > 0)
- hash = (hash * FNV_32_PRIME) ^ *buf++;
-
- return hash;
-}
-
-/* Fowler-Noll-Vo 32-bit hash, for strings. */
-unsigned
-hsh_hash_string (const char *s_)
-{
- const unsigned char *s = (const unsigned char *) s_;
- unsigned hash;
-
- assert (s != NULL);
-
- hash = FNV_32_BASIS;
- while (*s != '\0')
- hash = (hash * FNV_32_PRIME) ^ *s++;
-
- return hash;
-}
-
-/* Fowler-Noll-Vo 32-bit hash, for case-insensitive strings. */
-unsigned
-hsh_hash_case_string (const char *s_)
-{
- const unsigned char *s = (const unsigned char *) s_;
- unsigned hash;
-
- assert (s != NULL);
-
- hash = FNV_32_BASIS;
- while (*s != '\0')
- hash = (hash * FNV_32_PRIME) ^ toupper (*s++);
-
- return hash;
-}
-
-/* Hash for ints. */
-unsigned
-hsh_hash_int (int i)
-{
- return hsh_hash_bytes (&i, sizeof i);
-}
-
-/* Hash for double. */
-unsigned
-hsh_hash_double (double d)
-{
- if (!isnan (d))
- return hsh_hash_bytes (&d, sizeof d);
- else
- return 0;
-}
/* Hash tables. */
@@ -449,7 +380,7 @@ hsh_sort_copy (struct hsh_table *h)
to a pointer to that entry; otherwise returns a pointer to a
NULL entry which *must* be used to insert a new entry having
the same key data. */
-inline void **
+void **
hsh_probe (struct hsh_table *h, const void *target)
{
unsigned i;
@@ -611,7 +542,7 @@ hsh_dump (struct hsh_table *h)
void **entry = h->entries;
int i;
- printf (_("hash table:"));
+ printf ("hash table:");
for (i = 0; i < h->size; i++)
printf (" %p", *entry++);
printf ("\n");