+++ /dev/null
-/* HashKit
- * Copyright (C) 2009 Brian Aker
- * All rights reserved.
- *
- * Use and distribution licensed under the BSD license. See
- * the COPYING file in the parent directory for full text.
- */
-
-#include <libhashkit/common.h>
-
-/* FNV hash'es lifted from Dustin Sallings work */
-static uint64_t FNV_64_INIT= uint64_t(0xcbf29ce484222325);
-static uint64_t FNV_64_PRIME= uint64_t(0x100000001b3);
-static uint32_t FNV_32_INIT= 2166136261UL;
-static uint32_t FNV_32_PRIME= 16777619;
-
-uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context)
-{
- /* Thanks to pierre@demartines.com for the pointer */
- uint64_t hash= FNV_64_INIT;
- (void)context;
-
- for (size_t x= 0; x < key_length; x++)
- {
- hash *= FNV_64_PRIME;
- hash ^= (uint64_t)key[x];
- }
-
- return (uint32_t)hash;
-}
-
-uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context)
-{
- uint32_t hash= (uint32_t) FNV_64_INIT;
- (void)context;
-
- for (size_t x= 0; x < key_length; x++)
- {
- uint32_t val= (uint32_t)key[x];
- hash ^= val;
- hash *= (uint32_t) FNV_64_PRIME;
- }
-
- return hash;
-}
-
-uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context)
-{
- uint32_t hash= FNV_32_INIT;
- (void)context;
-
- for (size_t x= 0; x < key_length; x++)
- {
- uint32_t val= (uint32_t)key[x];
- hash *= FNV_32_PRIME;
- hash ^= val;
- }
-
- return hash;
-}
-
-uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context)
-{
- uint32_t hash= FNV_32_INIT;
- (void)context;
-
- for (size_t x= 0; x < key_length; x++)
- {
- uint32_t val= (uint32_t)key[x];
- hash ^= val;
- hash *= FNV_32_PRIME;
- }
-
- return hash;
-}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * HashKit library
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2009 Brian Aker All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+#include <libhashkit/common.h>
+
+/* FNV hash'es lifted from Dustin Sallings work */
+static uint32_t FNV_32_INIT= 2166136261UL;
+static uint32_t FNV_32_PRIME= 16777619;
+
+uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context)
+{
+ uint32_t hash= FNV_32_INIT;
+ (void)context;
+
+ for (size_t x= 0; x < key_length; x++)
+ {
+ uint32_t val= (uint32_t)key[x];
+ hash *= FNV_32_PRIME;
+ hash ^= val;
+ }
+
+ return hash;
+}
+
+uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context)
+{
+ uint32_t hash= FNV_32_INIT;
+ (void)context;
+
+ for (size_t x= 0; x < key_length; x++)
+ {
+ uint32_t val= (uint32_t)key[x];
+ hash ^= val;
+ hash *= FNV_32_PRIME;
+ }
+
+ return hash;
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * HashKit library
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2009 Brian Aker All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+#include <libhashkit/common.h>
+
+/* FNV hash'es lifted from Dustin Sallings work */
+static uint64_t FNV_64_INIT= 0xcbf29ce484222325LLU;
+static uint64_t FNV_64_PRIME= 0x100000001b3LLU;
+
+uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context)
+{
+ /* Thanks to pierre@demartines.com for the pointer */
+ uint64_t hash= FNV_64_INIT;
+ (void)context;
+
+ for (size_t x= 0; x < key_length; x++)
+ {
+ hash *= FNV_64_PRIME;
+ hash ^= (uint64_t)key[x];
+ }
+
+ return (uint32_t)hash;
+}
+
+uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context)
+{
+ uint32_t hash= (uint32_t) FNV_64_INIT;
+ (void)context;
+
+ for (size_t x= 0; x < key_length; x++)
+ {
+ uint32_t val= (uint32_t)key[x];
+ hash ^= val;
+ hash *= (uint32_t) FNV_64_PRIME;
+ }
+
+ return hash;
+}
libhashkit/behavior.cc \
libhashkit/crc32.cc \
libhashkit/digest.cc \
- libhashkit/fnv.cc \
+ libhashkit/fnv_32.cc \
+ libhashkit/fnv_64.cc \
libhashkit/function.cc \
libhashkit/hashkit.cc \
libhashkit/jenkins.cc \
return true;
}
-template <class T_comparable>
-bool _compare(const char *file, int line, const char *func, const T_comparable __expected, const T_comparable __actual)
+template <class T1_comparable, class T2_comparable>
+bool _compare(const char *file, int line, const char *func, const T1_comparable __expected, const T2_comparable __actual)
{
if (__expected != __actual)
{
return true;
}
-template <class T_comparable, class T_hint>
-bool _compare_hint(const char *file, int line, const char *func, T_comparable __expected, T_comparable __actual, T_hint __hint)
+template <class T1_comparable, class T2_comparable, class T_hint>
+bool _compare_hint(const char *file, int line, const char *func, T1_comparable __expected, T2_comparable __actual, T_hint __hint)
{
if (__expected != __actual)
{
test_compare(MEMCACHED_SUCCESS, rc);
test_true(value);
- test_compare(100UL, value_length);
+ test_compare(100LLU, value_length);
free(value);
}