X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libhashkit%2Ffnv.c;fp=libhashkit%2Ffnv.c;h=0000000000000000000000000000000000000000;hb=ae6bc7501efd5aeaaee92dabe2da0ec2d1625c5b;hp=fffb94a492aebf86815942322d9511f0825a7506;hpb=0f16555031c7f44d1acd034ff74e628c51a72dac;p=awesomized%2Flibmemcached diff --git a/libhashkit/fnv.c b/libhashkit/fnv.c deleted file mode 100644 index fffb94a4..00000000 --- a/libhashkit/fnv.c +++ /dev/null @@ -1,75 +0,0 @@ -/* 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 - -/* FNV hash'es lifted from Dustin Sallings work */ -static uint64_t FNV_64_INIT= UINT64_C(0xcbf29ce484222325); -static uint64_t FNV_64_PRIME= UINT64_C(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; -}