예제 #1
0
파일: cpphash.c 프로젝트: caivega/efl-1
/*
 * return hash function on name.  must be compatible with the one
 * computed a step at a time, elsewhere
 */
int
hashf(const char *name, int len, int hashsize)
{
   int                 r = 0;

   while (len--)
      r = HASHSTEP(r, *name++);

   return MAKE_POS(r) % hashsize;
}
예제 #2
0
/*
 * Return a 32-bit hash of the given buffer.  The init
 * value should be 0, or the previous hash value to extend
 * the previous hash.
 */
static uint32_t
hash32_buf(const void *buf, size_t len, uint32_t hash)
{
  const unsigned char *p = buf;

  while (len--)
    hash = HASHSTEP(hash, *p++);

  return hash;
}