key-value/kv.c
/**
 * @brief String hash function
 * @param word String to hash
 * @param max Upper bound for the index produced
 * @return Index in [0, max[
 */
@brief String hash function
@param word String to hash
@param max Upper bound for the index produced
@return Index in [0, max[
@brief String hash function @param word String to hash @param max Upper bound for the index produced @return Index in [ 0 max [
static size_t hash(const char *word, int32_t max)
{
    int32_t val = 5381;
    for (size_t counter = 0; word[counter] != '\0'; counter++) {
        val = val % (1 << 24);
        val = ((val << 5) + val) + word[counter];
    }
    return ((val % max) < 0) ? -val % max : val % max;
}
static size_t hash ( const char * word , int32_t max ) { int32_t val = 5381 ; for ( size_t counter = 0 ; word [ counter ] != ' \0 ' ; counter ++ ) { val = val % ( 1 << 24 ) ; val = ( ( val << 5 ) + val ) + word [ counter ] ; } return ( ( val % max ) < 0 ) ? - val % max : val % max ; }
@brief String hash function
 @param word String to hash
 @param max Upper bound for the index produced
 @return Index in [0, max[
@brief String hash function @param word String to hash @param max Upper bound for the index produced @return Index in [ 0 max [