"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/hash.c" (21 Feb 2022, 865 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "hash.c" see the Fossies "Dox" file reference documentation.

    1 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 
    3 #include "memcached.h"
    4 #include "jenkins_hash.h"
    5 #include "murmur3_hash.h"
    6 #define XXH_INLINE_ALL // modifier for xxh3's include below
    7 #include "xxhash.h"
    8 
    9 hash_func hash;
   10 
   11 static uint32_t XXH3_hash(const void *key, size_t length) {
   12     return (uint32_t)XXH3_64bits(key, length);
   13 }
   14 
   15 int hash_init(enum hashfunc_type type) {
   16     switch(type) {
   17         case JENKINS_HASH:
   18             hash = jenkins_hash;
   19             settings.hash_algorithm = "jenkins";
   20             break;
   21         case MURMUR3_HASH:
   22             hash = MurmurHash3_x86_32;
   23             settings.hash_algorithm = "murmur3";
   24             break;
   25         case XXH3_HASH:
   26             hash = XXH3_hash;
   27             settings.hash_algorithm = "xxh3";
   28             break;
   29         default:
   30             return -1;
   31     }
   32     return 0;
   33 }