/* Hash tables.
- Copyright (C) 2000-2005 Free Software Foundation, Inc.
+ Copyright (C) 2000-2006 Free Software Foundation, Inc.
This file is part of GNU Wget.
# define xnew_array(type, x) xmalloc (sizeof (type) * (x))
# define xmalloc malloc
# define xfree free
-# define countof(x) (sizeof (x) / sizeof ((x)[0]))
-# define TOLOWER(x) ('A' <= (x) && (x) <= 'Z' ? (x) - 32 : (x))
+# ifndef countof
+# define countof(x) (sizeof (x) / sizeof ((x)[0]))
+# endif
+# include <ctype.h>
+# define TOLOWER(x) tolower ((unsigned char) (x))
+# if __STDC_VERSION__ >= 199901L
+# include <stdint.h> /* for uintptr_t */
+# else
+ typedef unsigned long uintptr_t;
+# endif
#endif
#include "hash.h"
-1. This is acceptable because it still allows the use of
nonnegative integer keys. */
-#define INVALID_PTR ((void *) ~0UL)
+#define INVALID_PTR ((void *) ~(uintptr_t) 0)
#ifndef UCHAR_MAX
# define UCHAR_MAX 0xff
#endif
unsigned long
hash_pointer (const void *ptr)
{
- unsigned long key = (unsigned long) ptr;
+ uintptr_t key = (uintptr_t) ptr;
key += (key << 12);
key ^= (key >> 22);
key += (key << 4);
key ^= (key >> 2);
key += (key << 7);
key ^= (key >> 12);
-#if SIZEOF_LONG > 4
+#if SIZEOF_VOID_P > 4
key += (key << 44);
key ^= (key >> 54);
key += (key << 36);
key += (key << 39);
key ^= (key >> 44);
#endif
- return key;
+ return (unsigned long) key;
}
static int