src/components/pcp/linux-pcp.c
//-----------------------------------------------------------------------------
// stringHash: returns unsigned long value for hashed string.  See djb2, Dan
// Bernstein, http://www.cse.yorku.ca/~oz/hash.html Empirically a fast well
// distributed hash, not theoretically explained.  On a test system with 1857
// events, this gets about a 65% density in a 2000 element table; 35% of slots
// have dups; max dups was 4.
//-----------------------------------------------------------------------------
returns unsigned long value for hashed string.
returns unsigned long value for hashed string .
static unsigned int stringHash(char *str, unsigned int tableSize) 
{
  unsigned long hash = 5381;                             
  int c;
  while ((c = (*str++))) {                               
     hash = ((hash << 5) + hash) + c;                    
  }
  return (hash % tableSize);                             
}
static unsigned int stringHash ( char * str , unsigned int tableSize ) { unsigned long hash = 5381 ; int c ; while ( ( c = ( * str ++ ) ) ) { hash = ( ( hash << 5 ) + hash ) + c ; } return ( hash % tableSize ) ; }
stringHash: returns unsigned long value for hashed string.
stringHash : returns unsigned long value for hashed string .
// seed value. // ends when c == 0. // hash * 33 + c. // compute index and exit.