~ubuntu-dev/ubuntu/lucid/mutt/lucid-201002110857

« back to all changes in this revision

Viewing changes to hash.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-06-07 17:30:03 UTC
  • mto: (16.2.1 experimental) (2.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090607173003-rg37ui3h2bbv7wl0
Tags: upstream-1.5.19
ImportĀ upstreamĀ versionĀ 1.5.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#define SOMEPRIME 149711
30
30
 
31
 
int hash_string (const unsigned char *s, int n)
 
31
unsigned int hash_string (const unsigned char *s, unsigned int n)
32
32
{
33
 
  int h = 0;
 
33
  unsigned int h = 0;
34
34
 
35
 
#if 0
36
 
  while (*s)
37
 
    h += *s++;
38
 
#else
39
35
  while (*s)
40
36
    h += (h << 7) + *s++;
41
37
  h = (h * SOMEPRIME) % n;
42
 
  h = (h >= 0) ? h : h + n;
43
 
#endif
44
38
 
45
 
  return (h % n);
 
39
  return h;
46
40
}
47
41
 
48
42
HASH *hash_create (int nelem)